In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people don't understand the knowledge points of this article "How to load routes in laravel8", so Xiaobian summarizes the following contents for everyone. The contents are detailed, the steps are clear, and they have certain reference value. I hope everyone can gain something after reading this article. Let's take a look at this article "How to load routes in laravel8".
RouteServiceProvider In earlier versions of Laravel, RouteServiceProvider included a $namespace attribute. The value of this attribute is automatically added to the controller route definition and before calls to the actionhelper /method.
In Laravel 8.x, this property is by default. This means Laravel does not automatically prefix namespaces. Therefore, in new Laravel 8.x applications, controller routing definitions should be defined using standard PHP callable syntax: URL::actionnull
was commented out.
So loading routes in laravel8 requires adding namespaces, as follows.
use App\Http\Controllers\Admin\AdminController;Route::get('/admin', [AdminController::class, 'index']);
or may
use App\Http\Controllers\Admin;#Note: The second argument here is the array Route::get ('/admin',[Admin\AdminController::class, 'index']);
If this is a resource route, you would:
#Note that the second parameter here is class, string, do not pass array Route::resource ('/admin', Admin\AdminController::class);
Calls to action-related methods should use the same callable syntax:
action([Admin\AdminController::class, 'index']);return Redirect::action([Admin\AdminController::class, 'index']); Note
If you prefer the routing prefix for Laravel 7.x style controllers, you can simply add the $namespace attribute to RouteServiceProvider in your application.
The path is:
app/Providers/RouteServiceProvider.php
Find the file, uncomment the commented line of code and use the previous version's auto-load namespace. 29 lines
// protected $namespace = 'App\\Http\\Controllers'; The above is about the content of this article on "How to load routes in laravel8". I believe everyone has a certain understanding. I hope the content shared by Xiaobian will be helpful to everyone. If you want to know more relevant knowledge content, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.