Composer autoloader + slim framework - fatal error: Class 'Slim\Slim' not found?

Composer autoloader + slim framework - fatal error: Class 'Slim\Slim' not found?

如何使用composer autoloader加载slim?我有它在下面,

composer.json:

{
    "autoload": {
        "psr-4": {
            "Vendor\Namespace\": ""
        }
    }
}

index.php:

require dirname(__FILE__).'/vendor/autoload.php';

use \Slim\Slim;

Slim::registerAutoloader();

//Instantiate a Slim application:
$app = new Slim();

//Define a HTTP GET route:
$app->get('/', function () {
    echo "Hello!";
});

$app->get('/hello/:name/', function ($name) {
    echo "Hello, $name";
});

//Run the Slim application:
$app->run();

错误:

Fatal error: Class 'Slim\Slim' not found in C:...

有什么想法我错过了什么吗?

你可以只使用...

{
    "require": {
        "slim/slim": "2.*"
    }
}

http://docs.slimframework.com/

如果你更喜欢在 ext 下保持苗条(正如你在此处提到的 )而不是将其用作 composer 包,我相信这会起作用:

{
    "autoload": {
        "psr-0": {
            "": "ext/"
        }
    }
}