silexphp / Silex

[DEPRECATED -- Use Symfony instead] The PHP micro-framework based on the Symfony Components
https://silex.symfony.com
MIT License
3.58k stars 718 forks source link

Auto loader issue #333

Closed ylv closed 12 years ago

ylv commented 12 years ago

When I run this code

require_once __DIR__.'/../vendor/autoload.php';

use SilexExtension\MongoDbExtension;

$app = new Silex\Application();

$app->register(new SilexExtension\MongoDbExtension(), array(
    'mongodb.class_path' => __DIR__ . '/../vendor/mongodb/lib',
    'mongodb.connection' => array(
        'server' => 'mongodb://localhost',
        'options' => array(),
        'eventmanager' => function($eventmanager){}
    )
));

$app->get('/hello', function() { 
    return 'Hello!';
}); 

$app->run();

It produces these errors:

[Tue May 29 15:28:12 2012] [error] [client 127.0.0.1] PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Identifier "autoloader" is not defined.' in /home/yuan/projects/company/praise-apis/comment-system/trunk/vendor/pimple/pimple/lib/Pimple.php:78\nStack trace:\n#0 /home/yuan/projects/company/praise-apis/comment-system/trunk/vendor/fate/silex-extensions/src/SilexExtension/MongoDbExtension.php(61): Pimple->offsetGet('autoloader')\n#1 /home/yuan/projects/company/praise-apis/comment-system/trunk/vendor/silex/silex/src/Silex/Application.php(155): SilexExtension\MongoDbExtension->register(Object(Silex\Application))\n#2 /home/yuan/projects/company/praise-apis/comment-system/trunk/public/index.php(16): Silex\Application->register(Object(SilexExtension\MongoDbExtension), Array)\n#3 {main}\n thrown in /home/yuan/projects/company/praise-apis/comment-system/trunk/vendor/pimple/pimple/lib/Pimple.php on line 78

This code is using the most recently checked out code. I used the git clone and ran the build tool and copied everything from the skeleton folder, the moment i bring in any libraries this happens. I did notice that the change log says that the autoloader is now completely integrated with composer, so silex no longer handles namespace registration.

How do i make this code work? things seem to have changed quite drastically recently.

igorw commented 12 years ago

The autoloader service has been removed in favour of composer. In this case you're using the MongoDbExtension from fate/Silex-Extensions.

You should remove the mandango.class_path and use composer's autoloading instead. Since mandango has a composer.json which defines this autoloading, simply removing that config option should be enough.

@fabpot I told you so ;-).