11.08.2017 Views

codebright

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The Primers 19<br />

You can add as many dependencies as you like to your project. Go ahead, add a billion! Prove me<br />

wrong.<br />

Listen, do you want to know a secret? Do you promise not to tell? Woah, oh oh. Closer, let me<br />

whisper in your ear. Say the words you long to hear…<br />

Your dependencies can have their own dependencies.<br />

That’s right! Your dependencies are also Composer packages. They have their own composer.json<br />

files. This means that they have their own require section with a list of dependencies, and those<br />

dependencies might even have more dependencies.<br />

Even better news, is that Composer will manage and install these nested dependencies for you. How<br />

fantastic is that? Wolverine might need tools/claws, tools/yellow-mask, and power/regeneration<br />

but you don’t have to worry about that. As long as you require the xmen/wolverine package then<br />

Composer will take care of the rest.<br />

As for dependency versions, they can assume a number of different forms. For example, you might<br />

not care about minor updates to a component. In which case, you could use a wildcard within the<br />

version, like this:<br />

1 "xmen/gambit": "1.0.*"<br />

Now Composer will install the latest version that starts with 1.0. For example, if Gambit had versions<br />

1.0.0 and 1.0.1, then 1.0.1 would be installed.<br />

Your package might also have a minimum or maximum boundary for package versions. This can be<br />

defined using the greater-than and less-than operators.<br />

1 "xmen/gambit": ">1.0.0"<br />

The above example would be satisfied by any versions of the xmen/gambit package that have a<br />

greater version number than 1.0.0.<br />

1 "xmen/gambit": "1.0.0"<br />

2 "xmen/gambit": "=

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!