使用composer启动f3(无脂肪框架)

时间:2015-03-15 03:20:17

标签: php composer-php fat-free-framework

我从我的Downloads文件夹启动了我的php服务器,并使用composer包下载了f3框架。 我使用以下命令启动了服务器,它可以正常工作

php -S 0.0.0.0:8000

这是我的index.php文件

require_once __DIR__ . '/vendor/autoload.php';
$f3 = \Base::instance();

function() {
        echo 'Hello, world!';
    }

$f3->set('DEBUG', 1);
$f3->run();

我的项目位于名为f3_project的文件夹中。但是当我导航到时 " http://localhost:8000/f3_project/index.php"。它没有显示输出。

它说" Failed to load resource: the server responded with a status of 500 (Internal Server Error)"

正确地按照步骤安装composer。我该如何解决这个问题?有什么问题?

"在服务器中,这是我得到的错误 /f3_project/index.php - 语法错误,意外' $ f3' (T_VARIABLE)"

1 个答案:

答案 0 :(得分:2)

虽然可能并不明显,但PHP正在扼杀匿名函数的非法定义(“Hello world”)。

显然你的意思是将URI路由到这个函数。正确的语法是:

$f3->route('GET /',function(){
  echo 'Hello world!';
});
相关问题