true,'mode' => 'development']);$app->get("/ind">
当前位置:Gxlcms > PHP教程 > php框架-phpslim框架路由找不到

php框架-phpslim框架路由找不到

时间:2021-07-01 10:21:17 帮助过:28人阅读

require_once "slim/vendor/autoload.php";
$app = new \Slim\Slim(['debug' => true,'mode' => 'development']);
$app->get("/index", function() {
    echo "

Hello Slim World

"; }); $app->run();

在本机访问localhost/api.php/index有输出,但是在Ubuntu上居然是404 not found,这是为什么?
ps:这个框架资源也少。。。

回复内容:

require_once "slim/vendor/autoload.php";
$app = new \Slim\Slim(['debug' => true,'mode' => 'development']);
$app->get("/index", function() {
    echo "

Hello Slim World

"; }); $app->run();

在本机访问localhost/api.php/index有输出,但是在Ubuntu上居然是404 not found,这是为什么?
ps:这个框架资源也少。。。

找到了原因,因为未设置伪静态

#nginx
root        /Users/jackluo/Works/php/rest;

    location / {
        root    /Users/jackluo/Works/php/rest;
        index   index.html index.php;
        try_files $uri $uri/ /index.php?$args;
    }
#apache
【1】启动mod_rewrite——去掉#,#代表注释
LoadModule rewrite_module modules/mod_rewrite.so

【2】修改AllowOverride None为AllowOverride All
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other 
#  blocks below.
#

    AllowOverride All
    Require all granted
    

slim框架还是不错的,用起来挺有感觉的。http://dighash.com/ 一个简单的slim demo~

人气教程排行