Merge pull request #603 from Seldaek/composerfiles
Moved vendor/.composer/* up into vendor/, fixes #497pull/602/merge
commit
437dd36e7d
|
@ -3,6 +3,7 @@
|
||||||
* Schema: Added 'require-dev' for development-time requirements (tests, etc), install with --dev
|
* Schema: Added 'require-dev' for development-time requirements (tests, etc), install with --dev
|
||||||
* Schema: Removed 'recommend'
|
* Schema: Removed 'recommend'
|
||||||
* Schema: 'suggest' is now informational and can use any description for a package, not only a constraint
|
* Schema: 'suggest' is now informational and can use any description for a package, not only a constraint
|
||||||
|
* Break: .composer/autoload.php and other files in vendor/.composer have been moved to vendor/
|
||||||
* Added caching of repository metadata (faster startup times & failover if packagist is down)
|
* Added caching of repository metadata (faster startup times & failover if packagist is down)
|
||||||
* Added include_path support for legacy projects that are full of require_once statements
|
* Added include_path support for legacy projects that are full of require_once statements
|
||||||
* Added installation notifications API to allow better statistics on Composer repositories
|
* Added installation notifications API to allow better statistics on Composer repositories
|
||||||
|
|
|
@ -80,7 +80,7 @@ capable of autoloading all of the classes in any of the libraries that it
|
||||||
downloads. To use it, just add the following line to your code's bootstrap
|
downloads. To use it, just add the following line to your code's bootstrap
|
||||||
process:
|
process:
|
||||||
|
|
||||||
require 'vendor/.composer/autoload.php';
|
require 'vendor/autoload.php';
|
||||||
|
|
||||||
Woh! Now start using monolog! To keep learning more about Composer, keep
|
Woh! Now start using monolog! To keep learning more about Composer, keep
|
||||||
reading the "Basic Usage" chapter.
|
reading the "Basic Usage" chapter.
|
||||||
|
|
|
@ -136,10 +136,10 @@ but it makes life quite a bit simpler.
|
||||||
## Autoloading
|
## Autoloading
|
||||||
|
|
||||||
For libraries that specify autoload information, Composer generates a
|
For libraries that specify autoload information, Composer generates a
|
||||||
`vendor/.composer/autoload.php` file. You can simply include this file and you
|
`vendor/autoload.php` file. You can simply include this file and you
|
||||||
will get autoloading for free.
|
will get autoloading for free.
|
||||||
|
|
||||||
require 'vendor/.composer/autoload.php';
|
require 'vendor/autoload.php';
|
||||||
|
|
||||||
This makes it really easy to use third party code. For example: If your
|
This makes it really easy to use third party code. For example: If your
|
||||||
project depends on monolog, you can just start using classes from it, and they
|
project depends on monolog, you can just start using classes from it, and they
|
||||||
|
@ -168,13 +168,13 @@ be in your project root. An example filename would be `src/Acme/Foo.php`
|
||||||
containing an `Acme\Foo` class.
|
containing an `Acme\Foo` class.
|
||||||
|
|
||||||
After adding the `autoload` field, you have to re-run `install` to re-generate
|
After adding the `autoload` field, you have to re-run `install` to re-generate
|
||||||
the `vendor/.composer/autoload.php` file.
|
the `vendor/autoload.php` file.
|
||||||
|
|
||||||
Including that file will also return the autoloader instance, so you can store
|
Including that file will also return the autoloader instance, so you can store
|
||||||
the return value of the include call in a variable and add more namespaces.
|
the return value of the include call in a variable and add more namespaces.
|
||||||
This can be useful for autoloading classes in a test suite, for example.
|
This can be useful for autoloading classes in a test suite, for example.
|
||||||
|
|
||||||
$loader = require 'vendor/.composer/autoload.php';
|
$loader = require 'vendor/autoload.php';
|
||||||
$loader->add('Acme\Test', __DIR__);
|
$loader->add('Acme\Test', __DIR__);
|
||||||
|
|
||||||
In addition to PSR-0 autoloading, classmap is also supported. This allows
|
In addition to PSR-0 autoloading, classmap is also supported. This allows
|
||||||
|
@ -182,7 +182,7 @@ classes to be autoloaded even if they do not conform to PSR-0. See the
|
||||||
[autoload reference](04-schema.md#autoload) for more details.
|
[autoload reference](04-schema.md#autoload) for more details.
|
||||||
|
|
||||||
> **Note:** Composer provides its own autoloader. If you don't want to use
|
> **Note:** Composer provides its own autoloader. If you don't want to use
|
||||||
that one, you can just include `vendor/.composer/autoload_namespaces.php`,
|
that one, you can just include `vendor/autoload_namespaces.php`,
|
||||||
which returns an associative array mapping namespaces to directories.
|
which returns an associative array mapping namespaces to directories.
|
||||||
|
|
||||||
← [Intro](00-intro.md) | [Libraries](02-libraries.md) →
|
← [Intro](00-intro.md) | [Libraries](02-libraries.md) →
|
||||||
|
|
|
@ -25,7 +25,7 @@ use Composer\Util\Filesystem;
|
||||||
*/
|
*/
|
||||||
class AutoloadGenerator
|
class AutoloadGenerator
|
||||||
{
|
{
|
||||||
public function dump(RepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir)
|
public function dump(RepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $bcLinks = false)
|
||||||
{
|
{
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem();
|
||||||
$filesystem->ensureDirectoryExists($installationManager->getVendorPath());
|
$filesystem->ensureDirectoryExists($installationManager->getVendorPath());
|
||||||
|
@ -96,6 +96,17 @@ EOF;
|
||||||
}
|
}
|
||||||
file_put_contents($targetDir.'/autoload.php', $this->getAutoloadFile(true, true, (Boolean) $includePathFile));
|
file_put_contents($targetDir.'/autoload.php', $this->getAutoloadFile(true, true, (Boolean) $includePathFile));
|
||||||
copy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
|
copy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
|
||||||
|
|
||||||
|
// TODO BC feature, add E_DEPRECATED in autoload.php on April 30th, remove after May 30th
|
||||||
|
if ($bcLinks) {
|
||||||
|
file_put_contents($targetDir.'/.composer/autoload_namespaces.php', "<?php\n// Deprecated file, use the one in root of vendor dir\nreturn include dirname(__DIR__).'/autoload_namespaces.php';\n");
|
||||||
|
file_put_contents($targetDir.'/.composer/autoload_classmap.php', "<?php\n// Deprecated file, use the one in root of vendor dir\nreturn include dirname(__DIR__).'/autoload_classmap.php';\n");
|
||||||
|
file_put_contents($targetDir.'/.composer/autoload.php', "<?php\n// Deprecated file, use the one in root of vendor dir\nreturn include dirname(__DIR__).'/autoload.php';\n");
|
||||||
|
file_put_contents($targetDir.'/.composer/ClassLoader.php', "<?php\n// Deprecated file, use the one in root of vendor dir\nreturn include dirname(__DIR__).'/ClassLoader.php';\n");
|
||||||
|
if ($includePathFile) {
|
||||||
|
file_put_contents($targetDir.'/.composer/include_paths.php', "<?php\n// Deprecated file, use the one in root of vendor dir\nreturn include dirname(__DIR__).'/include_paths.php';\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages)
|
public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages)
|
||||||
|
|
|
@ -81,10 +81,10 @@ class Compiler
|
||||||
$this->addFile($phar, $file);
|
$this->addFile($phar, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/.composer/ClassLoader.php'));
|
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/ClassLoader.php'));
|
||||||
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/.composer/autoload.php'));
|
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/autoload.php'));
|
||||||
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/.composer/autoload_namespaces.php'));
|
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/autoload_namespaces.php'));
|
||||||
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/.composer/autoload_classmap.php'));
|
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../vendor/autoload_classmap.php'));
|
||||||
$this->addComposerBin($phar);
|
$this->addComposerBin($phar);
|
||||||
|
|
||||||
// Stubs
|
// Stubs
|
||||||
|
|
|
@ -151,8 +151,15 @@ class Factory
|
||||||
|
|
||||||
protected function addLocalRepository(RepositoryManager $rm, $vendorDir)
|
protected function addLocalRepository(RepositoryManager $rm, $vendorDir)
|
||||||
{
|
{
|
||||||
$rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/.composer/installed.json')));
|
// TODO BC feature, remove after May 30th
|
||||||
$rm->setLocalDevRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/.composer/installed_dev.json')));
|
if (file_exists($vendorDir.'/.composer/installed.json')) {
|
||||||
|
rename($vendorDir.'/.composer/installed.json', $vendorDir.'/installed.json');
|
||||||
|
}
|
||||||
|
if (file_exists($vendorDir.'/.composer/installed_dev.json')) {
|
||||||
|
rename($vendorDir.'/.composer/installed_dev.json', $vendorDir.'/installed_dev.json');
|
||||||
|
}
|
||||||
|
$rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/installed.json')));
|
||||||
|
$rm->setLocalDevRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/installed_dev.json')));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addPackagistRepository(array $localConfig)
|
protected function addPackagistRepository(array $localConfig)
|
||||||
|
|
|
@ -152,7 +152,7 @@ class Installer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// dump suggestions
|
// output suggestions
|
||||||
foreach ($this->suggestedPackages as $suggestion) {
|
foreach ($this->suggestedPackages as $suggestion) {
|
||||||
$this->io->write($suggestion['source'].' suggests installing '.$suggestion['target'].' ('.$suggestion['reason'].')');
|
$this->io->write($suggestion['source'].' suggests installing '.$suggestion['target'].' ('.$suggestion['reason'].')');
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ class Installer
|
||||||
$this->io->write('<info>Generating autoload files</info>');
|
$this->io->write('<info>Generating autoload files</info>');
|
||||||
$generator = new AutoloadGenerator;
|
$generator = new AutoloadGenerator;
|
||||||
$localRepos = new CompositeRepository($this->repositoryManager->getLocalRepositories());
|
$localRepos = new CompositeRepository($this->repositoryManager->getLocalRepositories());
|
||||||
$generator->dump($localRepos, $this->package, $this->installationManager, $this->installationManager->getVendorPath().'/.composer');
|
$generator->dump($localRepos, $this->package, $this->installationManager, $this->installationManager->getVendorPath(), true);
|
||||||
|
|
||||||
// dispatch post event
|
// dispatch post event
|
||||||
$eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
|
$eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
|
||||||
|
|
|
@ -16,7 +16,7 @@ function includeIfExists($file) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!$loader = includeIfExists(__DIR__.'/../vendor/.composer/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../.composer/autoload.php'))) {
|
if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
|
||||||
die('You must set up the project dependencies, run the following commands:'.PHP_EOL.
|
die('You must set up the project dependencies, run the following commands:'.PHP_EOL.
|
||||||
'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
|
'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
|
||||||
'php composer.phar install'.PHP_EOL);
|
'php composer.phar install'.PHP_EOL);
|
||||||
|
|
Loading…
Reference in New Issue