如何使用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();
错误:
致命错误:Class' Slim \ Slim'在C中找不到:......
我错过了哪些想法?
答案 0 :(得分:3)
答案 1 :(得分:1)
如果你喜欢在ext(如你在这里提到的Slim framework - How to autoload Slim/Slim.php instead of using require?)中保持苗条而不是将其用作作曲家包,我相信这会有效:
{
"autoload": {
"psr-0": {
"": "ext/"
}
}
}