浏览器中的 Slim 调用端点
Slim calling endpoint in browser
我是 Slim 的新手,我想创建一个小型网站,我使用 Slim 创建了一个 API 一切都很好,但是当我开始在浏览器中显示端点时,我堆栈。
使用 restful 测试仪或 curl ,它工作正常,但当我浏览时: path_to_index/hello ,我收到 404 错误。
使用 path_to_index/index.php/hello 它有效。我如何更改它才能使 path_to_index/hello 有效
这是我的索引:
require 'vendor/slim/slim/Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->get('/hello', function () {
echo "Hello";
});
$app->run();
我的.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
确保将您的 htaccess
放在您的 index.php
旁边 - 使用此设置。
使用 composer
时,您还可以 require
供应商自动加载器:
require 'vendor/autoload.php';
我是 Slim 的新手,我想创建一个小型网站,我使用 Slim 创建了一个 API 一切都很好,但是当我开始在浏览器中显示端点时,我堆栈。 使用 restful 测试仪或 curl ,它工作正常,但当我浏览时: path_to_index/hello ,我收到 404 错误。 使用 path_to_index/index.php/hello 它有效。我如何更改它才能使 path_to_index/hello 有效
这是我的索引:
require 'vendor/slim/slim/Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->get('/hello', function () {
echo "Hello";
});
$app->run();
我的.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
确保将您的
htaccess
放在您的index.php
旁边 - 使用此设置。使用
composer
时,您还可以require
供应商自动加载器:
require 'vendor/autoload.php';