Registering route exceptions under the Lumen Framework Controllers folder

Source: Internet
Author: User
1.lumen controllers Structure

    Controllers         --Test             --TestController.php         

2. Registering a route

$app->get("test",'Test\TestController@est');

3.lumen error;

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

4.Testcontroller Code:

    
  
   

namespace AppHttpControllersTest;

use AppHttpControllersController as Controller;

class TestController extends Controller
{

public function test(){ echo 1132;}

}
?>

该代码在Controllers下可以正常输出,但在ControllersTest文件夹下异常

lumen 版本 5.2.9

Reply content:

1.lumen controllers Structure

    Controllers         --Test             --TestController.php         

2. Registering a route

$app->get("test",'Test\TestController@est');

3.lumen error;

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

4.Testcontroller Code:

    
  
    

namespace AppHttpControllersTest;

use AppHttpControllersController as Controller;

class TestController extends Controller
{

public function test(){ echo 1132;}

}
?>

该代码在Controllers下可以正常输出,但在ControllersTest文件夹下异常

lumen 版本 5.2.9

看起来是找不到 AppHttpControllersTestTestController 这个类,路由定义是没错的,应该是类加载的问题。

你试着运行 php artisan tinker,然后在 shell 里运行 $foo = new App\Http\Controllers\Test\TestController; 看看能不能找到这个类。

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.