merged branch canni/composer (PR #3291)

Commits
-------

aa055df [Composer] Stwitch to composer vendors management

Discussion
----------

[Composer] Stwitch to composer vendors management

Bug fix: no
Feature addition: yes
Backwards compatibility break: No?
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -

[![Build Status](https://secure.travis-ci.org/canni/symfony.png?branch=composer)](http://travis-ci.org/canni/symfony)

This speeds up Travis CI builds to `~2 min` also makes vendor management
a lot easier.

---------------------------------------------------------------------------

by fabpot at 2012-02-09T06:24:24Z

I'm -1 on this change. The `vendors.php` script is *only* for people working on the core so that we can run the unit tests. So, we need the flexibility to test on many different versions of the code and having the repository here is kind of mandatory.

---------------------------------------------------------------------------

by Seldaek at 2012-02-09T08:15:28Z

You can `composer install --dev` to get proper clones. I'm not really pro or against, just saying it's an option.

---------------------------------------------------------------------------

by canni at 2012-02-09T08:28:54Z

@fabpot I understand yours point, but from my view transferring the whole git structure of *vendors* is little pointless IMO (especially in Travis env)
but I think I can make this change optional, so Travis and anyone that prefer to, can use `composer` an with old functionality available.

(There will be almost no duplication, as anyway we're updating `composer.json`)

---------------------------------------------------------------------------

by canni at 2012-02-09T09:20:17Z

@fabpot I've enabled both behaviors, everything will work regardless of using `composer` or `vendors.php` this lets the developer decide what to use

---------------------------------------------------------------------------

by drak at 2012-02-16T12:05:28Z

Since there is a `--dev` option in Composer then I think this is a good idea.  You could also add composer.phar to the repo bin  directory.

---------------------------------------------------------------------------

by henrikbjorn at 2012-02-16T12:06:55Z

`--dev` have been renamed to `--prefer-source`

---------------------------------------------------------------------------

by canni at 2012-02-16T12:22:01Z

@fabpot any chance to consider this merge? If not, this PR can be closed.

---------------------------------------------------------------------------

by henrikbjorn at 2012-02-16T12:25:51Z

@canni This is the goal eventually. But i think we need composer to be a bit more stable in its solver.

---------------------------------------------------------------------------

by francoispluchino at 2012-02-16T12:39:24Z

👍

---------------------------------------------------------------------------

by jmikola at 2012-04-06T18:19:27Z

@fabpot: Is this PR still off the table, or are you reconsidering it with the `--prefer-source` option? I was just running symfony unit tests, and attempted to install deps with composer as I thought this PR or another like it had recently been merged to core. It wasn't :)

Admittedly, it's a downside that vendor libs, even if git repositories, will be nestled within the `.composer/` directory.

---------------------------------------------------------------------------

by drak at 2012-04-07T00:20:33Z

@canni This PR needs to be rebased and reviewed because of the changed tests directory (there is no longer a central `tests/` folder).

---------------------------------------------------------------------------

by canni at 2012-04-07T06:34:28Z

Hey,

will do after a weekend.

canni

Użytkownik Drak <reply@reply.github.com> napisał:

>@canni This PR needs to be rebased and reviewed because of the changed tests directory (there is no longer a central `tests/` folder).
>
>---
>Reply to this email directly or view it on GitHub:
>https://github.com/symfony/symfony/pull/3291#issuecomment-5004750

---------------------------------------------------------------------------

by canni at 2012-04-08T19:02:03Z

@drak done.
This commit is contained in:
Fabien Potencier 2012-04-18 11:06:49 +02:00
commit 0669b61035
8 changed files with 49 additions and 108 deletions

View File

@ -5,4 +5,4 @@ php:
- 5.3
- 5.4
before_script: php vendors.php
before_script: wget http://getcomposer.org/composer.phar && php composer.phar --install-suggests install

View File

@ -1,40 +0,0 @@
<?php
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ClassLoader.php';
use Symfony\Component\ClassLoader\ClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;
$loader = new ClassLoader();
$loader->addPrefixes(array(
'Symfony\\Tests\\' => __DIR__.'/tests',
'Symfony\\' => __DIR__.'/src',
'Doctrine\\Common\\DataFixtures\\' => __DIR__.'/vendor/doctrine-fixtures/lib',
'Doctrine\\Common\\' => __DIR__.'/vendor/doctrine-common/lib',
'Doctrine\\DBAL\\' => __DIR__.'/vendor/doctrine-dbal/lib',
'Doctrine\\ORM\\' => __DIR__.'/vendor/doctrine/lib',
'Monolog\\' => __DIR__.'/vendor/monolog/src',
'Twig_' => __DIR__.'/vendor/twig/lib',
));
if (!function_exists('intl_get_error_code')) {
require_once __DIR__.'/src/Symfony/Component/Locale/Resources/stubs/functions.php';
$loader->addPrefix('', __DIR__.'/src/Symfony/Component/Locale/Resources/stubs');
}
if (!interface_exists('SessionHandlerInterface', false)) {
$loader->addPrefix('SessionHandlerInterface', __DIR__.'/src/Symfony/Component/HttpFoundation/Resources/stubs');
}
$loader->register();
if (is_file(__DIR__.'/vendor/doctrine-common/lib/Doctrine/Common/Annotations/AnnotationRegistry.php')) {
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
}
if (is_file(__DIR__.'/vendor/swiftmailer/lib/classes/Swift.php')) {
require_once __DIR__.'/vendor/swiftmailer/lib/classes/Swift.php';
Swift::registerAutoload(__DIR__.'/vendor/swiftmailer/lib/swift_init.php');
}
if (is_file($file = __DIR__.'/vendor/propel/runtime/lib/Propel.php')) {
require_once $file;
}

View File

@ -0,0 +1,27 @@
<?php
$loader = require_once __DIR__.'/vendor/.composer/autoload.php';
$loader->add('Symfony\\Tests', __DIR__.'/tests');
use Doctrine\Common\Annotations\AnnotationRegistry;
if (!function_exists('intl_get_error_code')) {
require_once __DIR__.'/src/Symfony/Component/Locale/Resources/stubs/functions.php';
$loader->add('IntlDateFormatter', __DIR__.'/src/Symfony/Component/Locale/Resources/stubs');
$loader->add('Collator', __DIR__.'/src/Symfony/Component/Locale/Resources/stubs');
$loader->add('Locale', __DIR__.'/src/Symfony/Component/Locale/Resources/stubs');
$loader->add('NumberFormatter', __DIR__.'/src/Symfony/Component/Locale/Resources/stubs');
}
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
AnnotationRegistry::registerFile(__DIR__.'/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
if (is_file(__DIR__.'/vendor/swiftmailer/swiftmailer/lib/classes/Swift.php')) {
require_once __DIR__.'/vendor/swiftmailer/swiftmailer/lib/classes/Swift.php';
Swift::registerAutoload(__DIR__.'/vendor/swiftmailer/swiftmailer/lib/swift_init.php');
}
if (is_file($file = __DIR__.'/vendor/propel/propel/runtime/lib/Propel.php')) {
require_once $file;
}

View File

@ -53,7 +53,10 @@
"symfony/yaml": "self.version"
},
"suggest": {
"doctrine/data-fixtures": "1.0.*"
"doctrine/dbal": "2.2.*",
"doctrine/orm": "2.2.*",
"doctrine/data-fixtures": "1.0.*",
"propel/propel1": "dev-master"
},
"autoload": {
"psr-0": {

View File

@ -9,7 +9,7 @@
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="autoload.php.dist"
bootstrap="composer.autoload.php.dist"
>
<testsuites>
<testsuite name="Symfony Test Suite">

View File

@ -22,6 +22,14 @@ while ($dir !== $lastDir) {
break;
}
if (
file_exists($dir.'/vendor/.composer/autoload.php')
&& file_exists($dir.'/composer.autoload.php.dist')
) {
require_once $dir.'/composer.autoload.php.dist';
break;
}
if (file_exists($dir.'/autoload.php.dist')) {
require_once $dir.'/autoload.php.dist';
break;

View File

@ -22,6 +22,14 @@ while ($dir !== $lastDir) {
break;
}
if (
file_exists($dir.'/vendor/.composer/autoload.php')
&& file_exists($dir.'/composer.autoload.php.dist')
) {
require_once $dir.'/composer.autoload.php.dist';
break;
}
if (is_file($dir.'/autoload.php.dist')) {
require_once $dir.'/autoload.php.dist';
break;

View File

@ -1,65 +0,0 @@
#!/usr/bin/env php
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
CAUTION: This file installs the dependencies needed to run the Symfony2 test suite.
If you want to create a new project, download the Symfony Standard Edition instead:
http://symfony.com/download
*/
set_time_limit(0);
if (!is_dir($vendorDir = dirname(__FILE__).'/vendor')) {
mkdir($vendorDir, 0777, true);
}
// optional transport change
$transport = false;
if (isset($argv[1]) && in_array($argv[1], array('--transport=http', '--transport=https', '--transport=git'))) {
$transport = preg_replace('/^--transport=(.*)$/', '$1', $argv[1]);
}
$deps = array(
array('doctrine', 'http://github.com/doctrine/doctrine2.git', 'origin/master'),
array('doctrine-dbal', 'http://github.com/doctrine/dbal.git', 'origin/master'),
array('doctrine-fixtures', 'https://github.com/doctrine/data-fixtures.git', 'origin/master'),
array('doctrine-common', 'http://github.com/doctrine/common.git', 'origin/master'),
array('twig', 'http://github.com/fabpot/Twig.git', 'origin/master'),
array('propel', 'http://github.com/propelorm/Propel.git', 'origin/master'),
array('monolog', 'https://github.com/Seldaek/monolog.git', 'origin/master'),
);
foreach ($deps as $dep) {
list($name, $url, $rev) = $dep;
if ($transport) {
$url = preg_replace('/^(http:|https:|git:)(.*)/', $transport . ':$2', $url);
}
$installDir = $vendorDir.'/'.$name;
$install = false;
if (!is_dir($installDir)) {
$install = true;
echo "> Installing $name\n";
system(sprintf('git clone %s %s', escapeshellarg($url), escapeshellarg($installDir)));
}
if (!$install) {
echo "> Updating $name\n";
}
system(sprintf('cd %s && git fetch origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($rev)));
}