Exception in registered routing under the Controllers folder of the lumen framework

WBOY
Release: 2016-09-24 09:15:13
Original
1420 people have browsed it

1.lumen Controllers structure

<code>    Controllers
         --Test
             --TestController.php
         </code>
Copy after login
Copy after login

2. Register route

<code>$app->get("test",'Test\TestController@est');
</code>
Copy after login
Copy after login

3.lumen reports an error;

<code>    lumen.ERROR: ReflectionException: Class App\Http\Controllers\Test\TestController does not exist in /Users/shumingjian/Desktop/www/lumen/vendor/illuminate/container/Container.php:734      
    </code>
Copy after login
Copy after login

4.Testcontroller code:

<code>    <?php
</code>
Copy after login
Copy after login

namespace AppHttpControllersTest;

use AppHttpControllersController as Controller;

class TestController extends Controller
{

<code>public function test(){
        echo 1132;
}</code>
Copy after login
Copy after login

}
?>

This code can be output normally under Controllers, but it is abnormal under the ControllersTest folder

lumen version 5.2.9

Reply content:

1.lumen Controllers structure

<code>    Controllers
         --Test
             --TestController.php
         </code>
Copy after login
Copy after login

2. Register route

<code>$app->get("test",'Test\TestController@est');
</code>
Copy after login
Copy after login

3.lumen reports an error;

<code>    lumen.ERROR: ReflectionException: Class App\Http\Controllers\Test\TestController does not exist in /Users/shumingjian/Desktop/www/lumen/vendor/illuminate/container/Container.php:734      
    </code>
Copy after login
Copy after login

4.Testcontroller code:

<code>    <?php
</code>
Copy after login
Copy after login

namespace AppHttpControllersTest;

use AppHttpControllersController as Controller;

class TestController extends Controller
{

<code>public function test(){
        echo 1132;
}</code>
Copy after login
Copy after login

}
?>

This code can be output normally under Controllers, but it is abnormal under the ControllersTest folder

lumen version 5.2.9

It seems that the AppHttpControllersTestTestController class cannot be found. The route definition is correct. It should be a class loading problem.

You try running php artisan tinker, and then run $foo = new AppHttpControllersTestTestController; in the shell to see if you can find this class.

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