11.08.2017 Views

codebright

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The Primers 18<br />

• Storm<br />

• Gambit<br />

There are loads of others, but these guys are pretty cool. We will stick with them for now. You see,<br />

we could copy the source files for these guys into our application directly, but then we would have to<br />

update them ourselves with any changes. That could get really boring. Let’s add them to the require<br />

section so that Composer will manage them for us.<br />

1 "require": {<br />

2 "xmen/wolverine": "1.0.0",<br />

3 "xmen/cyclops": "1.0.1",<br />

4 "xmen/storm": "1.2.0",<br />

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

6 }<br />

Here we are listing the packages for our mutant dependencies, and the versions that we would like<br />

to use. In this example, they all belong to the same owner as the X-Men package, but they could just<br />

as easily belong to another person.<br />

Most redistributable packages are hosted on a version control website such as Github⁷ or Bitbucket⁸.<br />

Version control repositories often have a tagging system where we can define stable versions of our<br />

application. For example with git we can use the command:<br />

1 git tag -a 1.0.0 -m 'First version.'<br />

With this we have created version 1.0.0 of our application. This is a stable release which people<br />

can depend on.<br />

Let’s have a closer look at the Gambit dependency.<br />

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

You should know by now that Composer package names consist of an owner and a package nickname<br />

separated by a forward slash (/) character. With this information we know that this is the gambit<br />

package written by the xmen user.<br />

Within the require section, the key for each item is the package name, and the value represents the<br />

required version.<br />

In the case of Gambit, the version number matches up to the tag available on Github where the code<br />

is versioned. Do you see how the versions of dependencies are now specific to our application, and<br />

not the whole system?<br />

⁷http://github.com<br />

⁸http://bitbucket.org

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

Saved successfully!

Ooh no, something went wrong!