Lumen routing cannot be accessed

WBOY
Release: 2023-03-03 10:48:01
Original
2474 people have browsed it

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

<code>$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');</code>
Copy after login
Copy after login

控制器

<code><?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]</code>
Copy after login
Copy after login

nginx配置如下

<code>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;
  }


}
</code>
Copy after login
Copy after login

.htaccess文件信息如下

<code><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>
</code>
Copy after login
Copy after login

目录结构
Lumen routing cannot be accessed
求解救啊

回复内容:

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

<code>$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');</code>
Copy after login
Copy after login

控制器

<code><?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]</code>
Copy after login
Copy after login

nginx配置如下

<code>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;
  }


}
</code>
Copy after login
Copy after login

.htaccess文件信息如下

<code><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>
</code>
Copy after login
Copy after login

目录结构
Lumen routing cannot be accessed
求解救啊

Composer autoload的没加吧?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template