User Tools

Site Tools


No renderer 'pdf' found for mode 'pdf'
php:composer

Composer

Composer is a PHP dependency manager. In other words, you (the developer) specify in a configuration file what PHP packages you want to use in your project, and Composer will automagically download the packages as well as any other packages needed by the packages you listed.

It also will generate an autoload.php file, which when required or included in your PHP script will automagicallay load all the packages it downloaded and let you refer to them using a standard namespacing scheme.

Init

The starting point is a file called composer.json that exists in the root of your project. You can manually create composer.json or you can issue:

$ compser init

to have composer scaffold out a composer.json file for you.

Once the composer.json file has been scaffolded out, you'll have to manually edit it to change it.1)

Specify your dependencies

Assuming you have a scaffolded composer.json file:

{
    "name": "mithat/foobar",
    "description": "A Composer example",
    "authors": [
        {
            "name": "Mithat Konar",
            "email": "no@you-dont-get-my-email-addy.com"
        }
    ],
    "require": {}
}

you specify packages you want to use (hereafter referred to as dependencies) as follows:

TODO

Using what Composer downloaded

TODO

Specifying versions

TODO

Development dependencies

TODO

Managing version changes (lock files)

TODO

1)
TODO: Is this true? Is there a composer command than will download a package and automatically add it to composer.json?
php/composer.txt · Last modified: 2016/07/14 20:22 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki