如何在文件夹应用程序内创建控制器,但在拉拉维尔的文件夹 http 外部创建控制器?



我在Laravel的文件夹应用程序中有一个文件夹Web。我想在文件夹 Web 中创建控制器。但是当我运行命令行时:

$ php artisan make:controller app/Web/Controllers/Webcontroller

默认情况下,它会在文件夹 Http/控制器内创建控制器。那么该怎么做呢?

你可以试试这个:

php artisan make:controller ../../App/Web/Controllers/WebController

或者按照 Jerodev 在问题评论中的建议手动创建控制器。

What laravel suggest is 
It is very important to note that we did not need to specify the full controller namespace when defining the controller route. Since the RouteServiceProvider loads your route files within a route group that contains the namespace, we only specified the portion of the class name that comes after the AppHttpControllers portion of the namespace.
If you choose to nest your controllers deeper into the AppHttpControllers directory, use the specific class name relative to the AppHttpControllers root namespace. So, if your full controller class is AppHttpControllersPhotosAdminController, you should register routes to the controller like so:
Route::get('foo', 'PhotosAdminController@method');
so if you create your controller out side Controllers directory you may have to do extra work for it to work.

相关内容

  • 没有找到相关文章

最新更新