Free Software Developer
https://github.com/naderman
phpBB Development Lead
https://www.phpbb.com
Composer Co-Author
https://getcomposer.org
Working at Forumatic
https://www.forumatic.com
Engine Yard Community Grant
https://www.engineyard.com
git clone https://github.com/symfony/standard-edition myproject
Cloning into myproject...
cd myproject/
curl -s http://getcomposer.org/installer | php
All settings correct for using Composer
Composer successfully installed to: /home/bob/myproject/composer.phar
Use it: php composer.phar
php composer.phar install
Installing from lock file
- Package twig/extensions (dev-master)
Downloading
Unpacking archive
Cleaning up
[...]
- Package twig/twig (1.8.0)
Downloading
Unpacking archive
Cleaning up
- Package symfony/symfony (dev-master)
Downloading
Unpacking archive
Cleaning up
Generating autoload files
vendor/ autoload.php composer/ monolog/ monolog/ symfony/ symfony/ monolog-bundle/ twig/ twig/ extensions/ [...]
{ "require": { "silex/silex": ">=1.0.0-dev", "symfony/finder": "2.1-dev", "twig/twig": "1.*", "predis/service-provider": "dev-master" "symfony/console": "~2.1" }, "require-dev": { "mikey179/vfsStream": "*" } }
user defined, configuration, version constraints
composer update
generated, package metadata, specific versions
composer install
dependencies' code and autoloader
composer status
Libraries/projects define their namespaces:
"autoload": { "psr-0": { "Vendor\\Namespace\\Component": "oldsrc/" }, "psr-4": { "Vendor\\Namespace\\Component": "src/" }, "classmap": ["lib/", "VeryOld.php"] }
oldsrc/Vendor/Namespace/Component/MyClass.php oldsrc/Vendor/Namespace/Component/ThatClass.php
src/MyClass.php src/ThatClass.php
Composer builds an autoloader for you:
vendor/autoload.php
Use the generated autoloader:
require __DIR__.'/../vendor/autoload.php'; use Silex\Application; use Silex\Extension\TwigExtension; use Symfony\Component\Finder\Finder; use Symfony\Component\HttpFoundation\Response; $app = new Application(); // ...
Regenerating the autoloader
composer dump-autoload
composer dump-autoload --no-dev --optimize
--no-dev
--prefer-source
--prefer-dist
--prefer-stable
--prefer-lowest
--ignore-platform-reqs
php composer.phar create-project composer/satis --stability=dev --keep-vcs
{ "name": "My Repository", "homepage": "http://packages.example.org", "repositories": [ {"type": "vcs", "url": "http://github.com/company/repo1"}, {"type": "vcs", "url": "http://svn.example.org/repo"}, {"type": "vcs", "url": "http://github.com/company/repo2"} ], "require-all": true }
{ "name": "My Repository", "homepage": "http://packages.example.org", "repositories": [ {"type": "vcs", "url": "http://github.com/company/repo1"}, {"type": "vcs", "url": "http://svn.example.org/repo"}, {"type": "vcs", "url": "http://github.com/company/repo2"} ], "require": { "company/package": "*", "company/package2": "*", "company/package3": "2.0.0" } }
{ "archive": { "directory": "dist", "format": "tar", "prefix-url": "https://amazing.cdn.example.org", "skip-dev": true } }
php bin/satis build config.json web/
"repositories": [{ "type": "composer", "url": "http://p.example.org/" }],
*nix: /home/example/.composer/config.json
Windows: C:\Users\example\AppData\Roaming\Composer\config.json
{ "repositories": [ { "type": "composer", "url": "http://p.example.org/" } ] }
Use composer config -g -e
to open the file
Symfony2, Laravel, Silex, Lithium ...
Assetic, Guzzle, Monolog, Twig, Imagine, ...