Permalink
Browse files

Merge remote-tracking branch 'upstream/master' into feature-dist

Conflicts:
	composer.lock
  • Loading branch information...
2 parents a1d287c + a8700fb commit fe6bac423054759ce3291dcc9bdada822e7152ac @till till committed Jun 26, 2012
Showing with 1,545 additions and 424 deletions.
  1. +1 −1 .travis.yml
  2. +1 −1 README.md
  3. +2 −1 composer.json
  4. +5 −5 composer.lock
  5. +1 −1 doc/00-intro.md
  6. +4 −3 doc/01-basic-usage.md
  7. +1 −1 doc/03-cli.md
  8. +3 −0 doc/05-repositories.md
  9. +2 −2 doc/dev/DefaultPolicy.md
  10. +26 −0 doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md
  11. +1 −1 doc/faqs/why-can't-composer-load-repositories-recursively.md
  12. +8 −22 src/Composer/Autoload/AutoloadGenerator.php
  13. +5 −5 src/Composer/Autoload/ClassLoader.php
  14. +3 −0 src/Composer/Autoload/ClassMapGenerator.php
  15. +3 −0 src/Composer/Cache.php
  16. +60 −6 src/Composer/Command/Command.php
  17. +2 −2 src/Composer/Command/CreateProjectCommand.php
  18. +1 −1 src/Composer/Command/DependsCommand.php
  19. +4 −5 src/Composer/Command/InitCommand.php
  20. +3 −4 src/Composer/Command/SearchCommand.php
  21. +5 −6 src/Composer/Command/ShowCommand.php
  22. +4 −0 src/Composer/Command/UpdateCommand.php
  23. +3 −4 src/Composer/Compiler.php
  24. +60 −0 src/Composer/Composer.php
  25. +55 −8 src/Composer/Config.php
  26. +15 −3 src/Composer/Console/Application.php
  27. +13 −0 src/Composer/DependencyResolver/Pool.php
  28. +34 −16 src/Composer/DependencyResolver/Problem.php
  29. +19 −8 src/Composer/DependencyResolver/Rule.php
  30. +7 −7 src/Composer/DependencyResolver/RuleSetGenerator.php
  31. +2 −1 src/Composer/DependencyResolver/Solver.php
  32. +7 −6 src/Composer/DependencyResolver/SolverProblemsException.php
  33. +3 −3 src/Composer/Downloader/DownloadManager.php
  34. +59 −7 src/Composer/Downloader/GitDownloader.php
  35. +23 −7 src/Composer/Downloader/PearDownloader.php
  36. +192 −0 src/Composer/Downloader/PearPackageExtractor.php
  37. +71 −59 src/Composer/Factory.php
  38. +19 −9 src/Composer/IO/ConsoleIO.php
  39. +7 −7 src/Composer/IO/IOInterface.php
  40. +5 −1 src/Composer/Installer.php
  41. +2 −2 src/Composer/Installer/InstallationManager.php
  42. +3 −3 src/Composer/Installer/InstallerInterface.php
  43. +1 −0 src/Composer/Installer/LibraryInstaller.php
  44. +2 −3 src/Composer/Installer/ProjectInstaller.php
  45. +6 −6 src/Composer/Json/JsonFile.php
  46. +2 −2 src/Composer/Package/AliasPackage.php
  47. +1 −1 src/Composer/Package/BasePackage.php
  48. +6 −0 src/Composer/Package/Link.php
  49. +2 −0 src/Composer/Package/LinkConstraint/LinkConstraintInterface.php
  50. +15 −0 src/Composer/Package/LinkConstraint/MultiConstraint.php
  51. +17 −0 src/Composer/Package/LinkConstraint/SpecificConstraint.php
  52. +16 −0 src/Composer/Package/LinkConstraint/VersionConstraint.php
  53. +9 −16 src/Composer/Package/Loader/RootPackageLoader.php
  54. +21 −15 src/Composer/Package/Locker.php
  55. +1 −1 src/Composer/Package/PackageInterface.php
  56. +9 −3 src/Composer/Package/Version/VersionParser.php
  57. +1 −1 src/Composer/Repository/ComposerRepository.php
  58. +11 −0 src/Composer/Repository/CompositeRepository.php
  59. +2 −0 src/Composer/Repository/PearRepository.php
  60. +56 −2 src/Composer/Repository/PlatformRepository.php
  61. +1 −1 src/Composer/Repository/RepositoryInterface.php
  62. +1 −1 src/Composer/Repository/RepositoryManager.php
  63. +45 −31 src/Composer/Repository/Vcs/SvnDriver.php
  64. +2 −2 src/Composer/Repository/Vcs/VcsDriver.php
  65. +2 −2 src/Composer/Repository/Vcs/VcsDriverInterface.php
  66. +8 −8 src/Composer/Util/Filesystem.php
  67. +2 −2 src/Composer/Util/RemoteFilesystem.php
  68. +6 −6 src/Composer/Util/Svn.php
  69. +3 −3 tests/Composer/Test/Autoload/Fixtures/autoload_functions.php
  70. +102 −0 tests/Composer/Test/ConfigTest.php
  71. +83 −3 tests/Composer/Test/DependencyResolver/SolverTest.php
  72. +21 −0 tests/Composer/Test/Downloader/Fixtures/Package_v1.0/package.xml
  73. +19 −0 tests/Composer/Test/Downloader/Fixtures/Package_v2.0/package.xml
  74. +25 −0 tests/Composer/Test/Downloader/Fixtures/Package_v2.1/package.xml
  75. +20 −14 tests/Composer/Test/Downloader/GitDownloaderTest.php
  76. +38 −0 tests/Composer/Test/Downloader/PearDownloaderTest.php
  77. +81 −0 tests/Composer/Test/Downloader/PearPackageExtractorTest.php
  78. +0 −66 tests/Composer/Test/FactoryTest.php
  79. +1 −1 tests/Composer/Test/InstallerTest.php
  80. +4 −6 tests/Composer/Test/Mock/FactoryMock.php
  81. +6 −0 tests/Composer/Test/Mock/InstallationManagerMock.php
  82. +31 −0 tests/Composer/Test/Mock/ProcessExecutorMock.php
  83. +8 −0 tests/Composer/Test/Package/LinkConstraint/VersionConstraintTest.php
  84. +52 −0 tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php
  85. +24 −8 tests/Composer/Test/Package/LockerTest.php
  86. +2 −0 tests/Composer/Test/Package/Version/VersionParserTest.php
  87. +24 −0 tests/Composer/Test/Repository/PearRepositoryTest.php
  88. +7 −1 tests/Composer/Test/Repository/Vcs/SvnDriverTest.php
  89. +5 −1 tests/Composer/Test/TestCase.php
  90. 0 tests/{phpunit.xml.dist → complete.phpunit.xml}
View
@@ -9,4 +9,4 @@ before_script:
- curl -s http://getcomposer.org/installer | php
- php composer.phar install
-script: phpunit -c tests/
+script: phpunit -c tests/complete.phpunit.xml
View
@@ -52,7 +52,7 @@ in a system wide way.
1. Change into a directory in your path like `cd /usr/local/bin`
2. Get Composer `curl -s http://getcomposer.org/installer | php`
-3. Make the phar executeable `chmod a+x composer.phar`
+3. Make the phar executable `chmod a+x composer.phar`
4. Change into a project directory `cd /path/to/my/project`
5. Use Composer as you normally would `composer.phar install`
6. Optionally you can rename the composer.phar to composer to make it easier
View
@@ -40,5 +40,6 @@
"branch-alias": {
"dev-master": "1.0-dev"
}
- }
+ },
+ "minimum-stability": "beta"
}
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -69,7 +69,7 @@ You can place this file anywhere you wish. If you put it in your `PATH`,
you can access it globally. On unixy systems you can even make it
executable and invoke it without `php`.
-You can run these commands to easily acces `composer` from anywhere on your system:
+You can run these commands to easily access `composer` from anywhere on your system:
$ curl -s http://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer
View
@@ -67,8 +67,9 @@ Version constraints can be specified in a few different ways.
example `1.0.2`. This is not used very often, but can be useful.
* **Range:** By using comparison operators you can specify ranges of valid
- versions. Valid operators are `>`, `>=`, `<`, `<=`. An example range would be
- `>=1.0`. You can define multiple ranges, separated by a comma: `>=1.0,<2.0`.
+ versions. Valid operators are `>`, `>=`, `<`, `<=`, `!=`. An example range
+ would be `>=1.0`. You can define multiple ranges, separated by a comma:
+ `>=1.0,<2.0`.
* **Wildcard:** You can specify a pattern with a `*` wildcard. `1.0.*` is the
equivalent of `>=1.0,<1.1-dev`.
@@ -105,7 +106,7 @@ and if it is, it downloads the versions specified there (regardless of what `com
says). This means that anyone who sets up the project will download the exact
same version of the dependencies.
-If no `composer.json` lock file exists, it will read the dependencies and
+If no `composer.lock` file exists, Composer will read the dependencies and
versions from `composer.json` and create the lock file.
This means that if any of the dependencies get a new version, you won't get the updates
View
@@ -254,7 +254,7 @@ If you are using composer from behind an HTTP proxy, you can use the standard
`http_proxy` or `HTTP_PROXY` env vars. Simply set it to the URL of your proxy.
Many operating systems already set this variable for you.
-Using `http_proxy` (lowercased) or even defining both might be preferrable since
+Using `http_proxy` (lowercased) or even defining both might be preferable since
some tools like git or curl will only use the lower-cased `http_proxy` version.
Alternatively you can also define the git proxy using
`git config --global http.proxy <proxy url>`.
View
@@ -252,6 +252,9 @@ Here is an example for the smarty template engine:
"url": "http://smarty-php.googlecode.com/svn/",
"type": "svn",
"reference": "tags/Smarty_3_1_7/distribution/"
+ },
+ "autoload": {
+ "classmap": ["libs/"]
}
}
}
View
@@ -2,10 +2,10 @@
A solver policy defines behaviour variables of the dependency solver. It decides
which versions are considered newer than others, which packages should be
-prefered over others and whether operations like downgrades or uninstall are
+preferred over others and whether operations like downgrades or uninstall are
allowed.
-## Selection of prefered Packages
+## Selection of preferred Packages
The following describe package pool situations with user requests and the
resulting order in which the solver will try to install them.
@@ -0,0 +1,26 @@
+# Should I commit the dependencies in my vendor directory?
+
+The general recommendation is **no**. The vendor directory (or wherever your
+dependencies are installed) should be added to `.gitignore`/`svn:ignore`/etc.
+
+The best practice is to then have all the developers use Composer to install
+the dependencies. Similarly, the build server, CI, deployment tools etc should
+be adapted to run Composer as part of their project bootstrapping.
+
+While it can be tempting to commit it in some environment, it leads to a few
+problems:
+
+- Large VCS repository size and diffs when you update code.
+- Duplication of the history of all your dependencies in your own VCS.
+- Adding dependencies installed via git to a git repo will show them as
+ submodules. This is problematic because they are not real submodules, and you
+ will run into issues.
+
+If you really feel like you must do this, you have two options:
+
+- Limit yourself to installing tagged releases (no dev versions), so that you
+ only get zipped installs, and avoid problems with the git "submodules".
+- Remove the .git directory of every dependency after the installation, then
+ you can add them to your git repo. You can do that with `rm -rf vendor/**/.git`
+ but this means you will have to delete those dependencies from disk before
+ running composer update.
@@ -26,7 +26,7 @@ could define the same packages inside a package repository, but with different
dist/source. There are many many ways this could go wrong.
- Fetch the repositories of root package, then fetch the repositories of the
-first level depencies, then fetch the repositories of their dependencies, etc,
+first level dependencies, then fetch the repositories of their dependencies, etc,
then resolve requirements. This sounds more efficient, but it suffers from the
same problems than the second solution, because loading the repositories of the
dependencies is not as easy as it sounds. You need to load all the repos of all
@@ -24,7 +24,7 @@
*/
class AutoloadGenerator
{
- public function dump(RepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $bcLinks = false)
+ public function dump(RepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir)
{
$filesystem = new Filesystem();
$filesystem->ensureDirectoryExists($installationManager->getVendorPath());
@@ -124,30 +124,16 @@ public function dump(RepositoryInterface $localRepo, PackageInterface $mainPacka
$filesCode = "";
$autoloads['files'] = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($autoloads['files']));
foreach ($autoloads['files'] as $functionFile) {
- $filesCode .= 'require __DIR__ . '. var_export('/'.$filesystem->findShortestPath($vendorPath, $functionFile), true).";\n";
+ $filesCode .= ' require __DIR__ . '. var_export('/'.$filesystem->findShortestPath($vendorPath, $functionFile), true).";\n";
}
file_put_contents($targetDir.'/autoload_namespaces.php', $namespacesFile);
file_put_contents($targetDir.'/autoload_classmap.php', $classmapFile);
if ($includePathFile = $this->getIncludePathsFile($packageMap, $filesystem, $relVendorPath, $vendorPath, $vendorPathCode, $appBaseDirCode)) {
file_put_contents($targetDir.'/include_paths.php', $includePathFile);
}
- file_put_contents($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, true, true, (Boolean) $includePathFile, $targetDirLoader, $filesCode));
+ file_put_contents($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, true, true, (bool) $includePathFile, $targetDirLoader, $filesCode));
copy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
-
- // TODO BC feature, remove after June 15th
- if ($bcLinks) {
- $filesystem->ensureDirectoryExists($vendorPath.'/.composer');
- $deprecated = "// Deprecated file, use the one in root of vendor dir\n".
- "trigger_error(__FILE__.' is deprecated, please use vendor/autoload.php or vendor/composer/autoload_* instead'.PHP_EOL.'See https://groups.google.com/forum/#!msg/composer-dev/fWIs3KocwoA/nU3aLko9LhQJ for details', E_USER_DEPRECATED);\n";
- file_put_contents($vendorPath.'/.composer/autoload_namespaces.php', "<?php\n{$deprecated}\nreturn include dirname(__DIR__).'/composer/autoload_namespaces.php';\n");
- file_put_contents($vendorPath.'/.composer/autoload_classmap.php', "<?php\n{$deprecated}\nreturn include dirname(__DIR__).'/composer/autoload_classmap.php';\n");
- file_put_contents($vendorPath.'/.composer/autoload.php', "<?php\n{$deprecated}\nreturn include dirname(__DIR__).'/autoload.php';\n");
- file_put_contents($vendorPath.'/.composer/ClassLoader.php', "<?php\n{$deprecated}\nreturn include dirname(__DIR__).'/composer/ClassLoader.php';\n");
- if ($includePathFile) {
- file_put_contents($vendorPath.'/.composer/include_paths.php', "<?php\n{$deprecated}\nreturn include dirname(__DIR__).'/composer/include_paths.php';\n");
- }
- }
}
public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages)
@@ -300,7 +286,7 @@ protected function getAutoloadFile($vendorPathToTargetDirCode, $usePSR0, $useCla
if (!class_exists('Composer\\\\Autoload\\\\ClassLoader', false)) {
require $vendorPathToTargetDirCode . '/ClassLoader.php';
}
-$filesCode
+
return call_user_func(function() {
\$loader = new \\Composer\\Autoload\\ClassLoader();
\$composerDir = $vendorPathToTargetDirCode;
@@ -342,10 +328,10 @@ protected function getAutoloadFile($vendorPathToTargetDirCode, $usePSR0, $useCla
$file .= $targetDirLoader;
- return $file . <<<'FOOTER'
- $loader->register();
-
- return $loader;
+ return $file . <<<FOOTER
+ \$loader->register();
+$filesCode
+ return \$loader;
});
FOOTER;
@@ -102,7 +102,7 @@ public function add($prefix, $paths)
/**
* Turns on searching the include path for class files.
*
- * @param Boolean $useIncludePath
+ * @param bool $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
@@ -113,7 +113,7 @@ public function setUseIncludePath($useIncludePath)
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
- * @return Boolean
+ * @return bool
*/
public function getUseIncludePath()
{
@@ -123,7 +123,7 @@ public function getUseIncludePath()
/**
* Registers this instance as an autoloader.
*
- * @param Boolean $prepend Whether to prepend the autoloader or not
+ * @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
@@ -141,8 +141,8 @@ public function unregister()
/**
* Loads the given class or interface.
*
- * @param string $class The name of the class
- * @return Boolean|null True, if loaded
+ * @param string $class The name of the class
+ * @return bool|null True, if loaded
*/
public function loadClass($class)
{
@@ -89,6 +89,9 @@ private static function findClasses($path)
{
$contents = file_get_contents($path);
try {
+ if (!preg_match('{\b(?:class|interface|trait)\b}i', $contents)) {
+ return array();
+ }
$tokens = token_get_all($contents);
} catch (\Exception $e) {
throw new \RuntimeException('Could not scan for classes inside '.$path.": \n".$e->getMessage(), 0, $e);
View
@@ -44,6 +44,7 @@ public function getRoot()
public function read($file)
{
+ $file = preg_replace('{[^a-z0-9.]}i', '-', $file);
if ($this->enabled && file_exists($this->root . $file)) {
return file_get_contents($this->root . $file);
}
@@ -52,12 +53,14 @@ public function read($file)
public function write($file, $contents)
{
if ($this->enabled) {
+ $file = preg_replace('{[^a-z0-9.]}i', '-', $file);
file_put_contents($this->root . $file, $contents);
}
}
public function sha1($file)
{
+ $file = preg_replace('{[^a-z0-9.]}i', '-', $file);
if ($this->enabled && file_exists($this->root . $file)) {
return sha1_file($this->root . $file);
}
@@ -12,6 +12,10 @@
namespace Composer\Command;
+use Composer\Composer;
+use Composer\Console\Application;
+use Composer\IO\IOInterface;
+use Composer\IO\NullIO;
use Symfony\Component\Console\Command\Command as BaseCommand;
/**
@@ -23,18 +27,68 @@
abstract class Command extends BaseCommand
{
/**
- * @return \Composer\Composer
+ * @var Composer
*/
- protected function getComposer($required = true)
+ private $composer;
+
+ /**
+ * @var IOInterface
+ */
+ private $io;
+
+ /**
+ * @param bool $required
+ * @return Composer
+ */
+ public function getComposer($required = true)
+ {
+ if (null === $this->composer) {
+ $application = $this->getApplication();
+ if ($application instanceof Application) {
+ /* @var $application Application */
+ $this->composer = $application->getComposer($required);
+ } elseif ($required) {
+ throw new \RuntimeException(
+ 'Could not create a Composer\Composer instance, you must inject '.
+ 'one if this command is not used with a Composer\Console\Application instance'
+ );
+ }
+ }
+
+ return $this->composer;
+ }
+
+ /**
+ * @param Composer $composer
+ */
+ public function setComposer(Composer $composer)
{
- return $this->getApplication()->getComposer($required);
+ $this->composer = $composer;
+ }
+
+ /**
+ * @return IOInterface
+ */
+ public function getIO()
+ {
+ if (null === $this->io) {
+ $application = $this->getApplication();
+ if ($application instanceof Application) {
+ /* @var $application Application */
+ $this->io = $application->getIO();
+ } else {
+ $this->io = new NullIO();
+ }
+ }
+
+ return $this->io;
}
/**
- * @return \Composer\IO\ConsoleIO
+ * @param IOInterface $io
*/
- protected function getIO()
+ public function setIO(IOInterface $io)
{
- return $this->getApplication()->getIO();
+ $this->io = $io;
}
}
Oops, something went wrong.

0 comments on commit fe6bac4

Please sign in to comment.