php - Lumen 路由无法访问访问

查看:156
本文介绍了php - Lumen 路由无法访问访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

我按照文档里的路由进行配置但是还是无法访问
路由

$app->get('/', function () use ($app) {
    $foo = new App\Http\Controllers\ExampleController();
    var_dump($foo);
    return $app->version();
});

$app->get('/info', function (){
    phpinfo();
});
$app->get('api', 'Api\WxController@test');
$app->get('ex','  ExampleController@test');

控制器

<?php

namespace App\Http\Controllers;
use Laravel\Lumen\Routing\Controller as BaseController;
class ExampleController extends BaseController
{
    /**
     * Create a new controller instance.
     *
     *wsk
     * wsk
     * @return void
     */
    public function __construct()
    {
        //
    }
  public  function test(){
      echo 998;
  }
    //
}
![图片描述][1]

nginx配置如下

server {
    listen       80;

    server_name  open.wesai.com;
    root    /opt/xxx/wservice/public;












location / {
        index  index.html index.php;

        if (!-e $request_filename) {
            rewrite ^/(.*) /index.php last;
        }
    }

    location ~ \.php$ {
        fastcgi_pass   unix:/var/run/php-fpm/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        #fastcgi_connect_timeout 30;
        #fastcgi_send_timeout 30;
        fastcgi_read_timeout 30;
        fastcgi_split_path_info       ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        include        fastcgi_params;
  }


}

.htaccess文件信息如下

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

目录结构

求解救啊

解决方案

Composer autoload的没加吧?

这篇关于php - Lumen 路由无法访问访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆