使用 composer 启动 f3(fat free 框架)

start f3 (fat free framework) using composer

我从我的下载文件夹启动了我的 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.How 我应该解决这个问题吗?有什么问题?

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

虽然可能不是很明显,PHP 是因为你的匿名函数定义不合法 ("Hello world")。

显然您打算将 URI 路由到此函数。正确的语法是:

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