Skip to content

Commit

Permalink
Switch deps loading mode to composer
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Feb 27, 2012
1 parent 32a0f51 commit 214c0bb
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 32 deletions.
43 changes: 14 additions & 29 deletions app/autoload.php
Original file line number Diff line number Diff line change
@@ -1,50 +1,35 @@
<?php

use Symfony\Component\ClassLoader\UniversalClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;
if (!$loader = include __DIR__.'/../vendor/.composer/autoload.php') {
$nl = PHP_SAPI === 'cli' ? PHP_EOL : '<br />';
die('You must set up the project dependencies, run the following commands:'.PHP_EOL.
'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
'php composer.phar install'.PHP_EOL);
}

$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
'Symfony' => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'),
'Sensio' => __DIR__.'/../vendor/bundles',
'JMS' => __DIR__.'/../vendor/bundles',
'Doctrine\\Bundle' => __DIR__.'/../vendor/bundles',
'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
'Doctrine\\DBAL' => __DIR__.'/../vendor/doctrine-dbal/lib',
'Doctrine' => __DIR__.'/../vendor/doctrine/lib',
'Monolog' => __DIR__.'/../vendor/monolog/src',
'Assetic' => __DIR__.'/../vendor/assetic/src',
'Metadata' => __DIR__.'/../vendor/metadata/src',
));
$loader->registerPrefixes(array(
'Twig_Extensions_' => __DIR__.'/../vendor/twig-extensions/lib',
'Twig_' => __DIR__.'/../vendor/twig/lib',
));
use Doctrine\Common\Annotations\AnnotationRegistry;

// intl
if (!function_exists('intl_get_error_code')) {
require_once __DIR__.'/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';

$loader->registerPrefixFallback(__DIR__.'/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs');
$loader->add('IntlDateFormatter', __DIR__.'/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs');
$loader->add('Collator', __DIR__.'/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs');
$loader->add('Locale', __DIR__.'/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs');
$loader->add('NumberFormatter', __DIR__.'/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs');
}

if (!interface_exists('SessionHandlerInterface', false)) {
$loader->registerPrefix('SessionHandlerInterface', __DIR__.'/../vendor/symfony/src/Symfony/Component/HttpFoundation/Resources/stubs');
$loader->add('SessionHandlerInterface', __DIR__.'/../vendor/symfony/src/Symfony/Component/HttpFoundation/Resources/stubs');
}

$loader->registerNamespaceFallbacks(array(
__DIR__.'/../src',
));

$loader->register();

AnnotationRegistry::registerLoader(function($class) use ($loader) {
$loader->loadClass($class);
return class_exists($class, false);
});
AnnotationRegistry::registerFile(__DIR__.'/../vendor/doctrine/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
AnnotationRegistry::registerFile(__DIR__.'/../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');

// Swiftmailer needs a special autoloader to allow
// the lazy loading of the init file (which is expensive)
require_once __DIR__.'/../vendor/swiftmailer/lib/classes/Swift.php';
require_once __DIR__.'/../vendor/swiftmailer/swiftmailer/lib/classes/Swift.php';
Swift::registerAutoload(__DIR__.'/../vendor/swiftmailer/lib/swift_init.php');
2 changes: 1 addition & 1 deletion app/console
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

set_time_limit(0);

require_once __DIR__.'/bootstrap.php.cache';
require_once __DIR__.'/autoload.php';
require_once __DIR__.'/AppKernel.php';

use Symfony\Bundle\FrameworkBundle\Console\Application;
Expand Down
49 changes: 49 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.2",
"symfony/symfony": "2.0.7",
"doctrine/dbal": "2.1.5",
"doctrine/orm": "2.1.4",
"twig/extensions": "master-dev",
"symfony/assetic-bundle": "master-dev",
"sensio/distribution-bundle": "2.0-dev",
"sensio/framework-extra-bundle": "2.0-dev",
"sensio/generator-bundle": "master-dev",
"jms/security-extra-bundle": "1.0.*",
"metadata/metadata": "1.1.0"
},
"repositories": {
"metadata": {
"package": {
"name": "metadata/metadata",
"version": "1.1.0",
"source": {
"type": "git",
"url": "http://github.com/schmittjoh/metadata.git",
"reference": "1.1.0"
},
"autoload": {
"psr-0": { "Metadata": "src/" }
}
}
},
"security-extra-bundle": {
"package": {
"name": "jms/security-extra-bundle",
"version": "1.0.1-dev",
"source": {
"type": "git",
"url": "http://github.com/schmittjoh/JMSSecurityExtraBundle.git",
"reference": "1.0.x"
},
"autoload": {
"psr-0": { "JMS\\SecurityExtraBundle": "" }
},
"target-dir": "JMS/SecurityExtraBundle"
}
}
}
}
1 change: 1 addition & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/app.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/autoload.php';
require_once __DIR__.'/../app/AppKernel.php';
//require_once __DIR__.'/../app/AppCache.php';

Expand Down
2 changes: 1 addition & 1 deletion web/app_dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}

require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/autoload.php';
require_once __DIR__.'/../app/AppKernel.php';

use Symfony\Component\HttpFoundation\Request;
Expand Down

0 comments on commit 214c0bb

Please sign in to comment.