I am attempting to create a composer package for Laravel 6 but I can not get my main route /
to override the default /
route included with the base Laravel installation.
(我正在尝试为Laravel 6创建一个composer软件包,但是我无法获取主路径/
来覆盖基本Laravel安装中包含的默认/
路径。)
My package route does works when I comment out the base /
route provided by laravel so it is being registered by the package.
(当我注释掉laravel提供的基础/
路由时,我的包裹路线确实有效,因此包裹正在对其进行注册。)
It doesn't make any different if I include my package's service provider before or after the RouteServiceProvider in the config/app.php
file.
(如果我在config/app.php
文件中的RouteServiceProvider之前或之后包含程序包的服务提供程序,则没有什么不同。)
What am I missing here?
(我在这里想念什么?)
How do I ensure my package routes have priority? (如何确保包裹路线优先?)
Here are the relevant bits of code:
(以下是相关的代码位:)
config/app.php
/*
* Application Service Providers...
*/
AppProvidersAppServiceProvider::class,
AppProvidersAuthServiceProvider::class,
// AppProvidersBroadcastServiceProvider::class,
AppProvidersEventServiceProvider::class,
WheelmakerLaravueSpaLaravueSpaServiceProvider::class, // MY SERVICE PROVIDER
AppProvidersRouteServiceProvider::class,
The relevant section of LaravueSpaServiceProvider
(LaravueSpaServiceProvider
的相关部分)
public function boot()
{
$this->loadRoutesFrom(__DIR__.'/routes/web.php');
...
}
My Package's web.php
route file:
(我的包裹的web.php
路由文件:)
<?php
Route::get('/', function(){
$initData = [
'appName' => config('app.name'),
'user' => Auth::user(),
];
return view('laravue-spa::app', compact('initData'));
})->middleware(['web']);
ask by wheelmaker translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…