Example
Edit composer.json
., (*1)
{
"require": {
"symfony/filesystem": "~2.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"ngyuki/composer-shared-installer": "*"
},
"extra": {
"shared": {
"exclude": [
"phpunit/phpunit"
]
}
}
}
Run composer update
command., (*2)
$ composer update
Create sample.php
., (*3)
<?php
require 'vendor/autoload.php';
use Symfony\Component\Filesystem\Filesystem;
$ref = new ReflectionClass('Symfony\Component\Filesystem\Filesystem');
echo $ref->getFileName(), PHP_EOL;
$ref = new ReflectionClass('PHPUnit_Framework_TestCase');
echo $ref->getFileName(), PHP_EOL;
Run sample.php
., (*4)
$ php sample.php
Symfony Filesystem will be installed global., (*5)
/home/your/.composer/shared/symfony/filesystem-2.3.6.0/Symfony/Component/Filesystem/Filesystem.php
PHPUnit will be installed local, because your exclude it., (*6)
/home/your/project/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php