> 백엔드 개발 > PHP 튜토리얼 > Lumen 라우팅에 액세스할 수 없습니다.

Lumen 라우팅에 액세스할 수 없습니다.

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
풀어 주다: 2023-03-03 10:48:01
원래의
2571명이 탐색했습니다.

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

1

2

3

4

5

6

7

8

9

10

11

<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>

로그인 후 복사
로그인 후 복사

控制器

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

<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>

로그인 후 복사
로그인 후 복사

nginx配置如下

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

<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>

로그인 후 복사
로그인 후 복사

.htaccess文件信息如下

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<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>

로그인 후 복사
로그인 후 복사

目录结构
Lumen 라우팅에 액세스할 수 없습니다.
求解救啊

回复内容:

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

1

2

3

4

5

6

7

8

9

10

11

<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>

로그인 후 복사
로그인 후 복사

控制器

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

<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>

로그인 후 복사
로그인 후 복사

nginx配置如下

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

<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>

로그인 후 복사
로그인 후 복사

.htaccess文件信息如下

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<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>

로그인 후 복사
로그인 후 복사

目录结构
Lumen 라우팅에 액세스할 수 없습니다.
求解救啊

Composer autoload的没加吧?

관련 라벨:
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿