Accès direct au contenu Accès direct à la navigation

This document explains how to install one of our packages, include it in your work and use it in your code.

You can install and include one of our packages in many ways :

  • make a clone of the package’s GitHub repository
  • download an archive of the package’s sources from the GitHub repository
  • use our package’s "packagist" from Composer

Clone a repository

First, you can clone the package’s GitHub repository and include it "as is" in your poject. This solution allows you to follow sources updates running a checkout on your clone regularily.

To clone a repository just run :

  1. ~$ git clone git://github.com/atelierspierrot/PACKAGE_NAME.git path/to/your/project
  2. Cloning into ...
  3. ...

If nothing went wrong, you will finally have a full copy of the repository with a .git/ directory meaning that your version is under version-control.

See the Including namespaces section to learn how to include the package’s scripts in your project.

Download an archive

You can also download an archive of the package repository from GitHub. To do so, just go to the GitHub homepage of the repository and click on the "ZIP" button. This way, you will have the last version of the "master" branch.

If you prefer to make this download from the command line, you can run :

  1. ~$ wget --no-check-certificate https://github.com/atelierspierrot/PACKAGE_NAME/archive/master.tar.gz
  2. ~$ tar -xvf master.tar.gz
  3. ~$ cp -r PACKAGE_NAME path/to/your/project/

If some are availables, it is a good practice to download a TAG from the GitHub repository as they may be a stable version. To have a list of tags, browse to :

http://github.com/atelierspierrot/PACKAGE_NAME/tags

See the Including namespaces section to learn how to include the package’s scripts in your project.

Using Composer

If you use Composer to manage your project’s dependencies, including it is as easy as adding to your composer.json file :

  1. "require": {
  2.     #...
  3.     "atelierspierrot/PACKAGE_NAME": "dev-master"
  4. },

Some of our packages are registered in the Packagist so that you don’t need to do more than adding the package name to your "rqeuirements". For all other packages, you will need to add the GitHub to the repositories entry of your composer.json manifest like :

  1. "repositories": [
  2.     #...
  3.     { "type": "vcs", "url": "http://github.com/atelierspierrot/PACKAGE_NAME" }
  4. ],

In certain cases, you can create a project directly from Composer running :

  1. ~$ php path/to/composer.phar create-project atelierspierrot/PACKAGE_NAME path/to/your/project dev-master --no-dev

You can select a specific version replacing dev-master by the version number.

Including namepsaces

As explained in the Coding & naming rules document, we almost try to follow the classic naming rules in PHP coding : each package as its own namespace and every class in the package follows the standard naming rule.

For example, if your want to read the Patterns\Interfaces\ArrayInterface code, you will find it in file src/Patterns/Interfaces/ArratInterface.php in the package.

So, to use some package’s classes in your work, you just need to register their namespaces directories using the SplClassLoader or any other custom autoloader. A copy of the "SplClassLoader" is often included in the packages, in the src/ directory.

For example, to register the WebFilesystem namespace, you need to write :

  1. require_once '/path/to/package/src/SplClassLoader.php';
  2. $classLoader = new SplClassLoader('WebFilesystem', '/path/to/package/src');
  3. $classLoader->register();

If you included one of our packages using Composer as explained above, all the package namspaces are automatically integrated in the autoloader. In this case, you have nothing to do to load the classes but define the use statement in your scripts.