weixin_39854923
2020-12-28 06:28external routes
Hi, I'm trying to load a separate routes file.
I've tried loading them from my own provider.
$routeFile = base_path('/Modules/Test/Routes/web.php');
event(new LoadRouteFile($routeFile));
if ($routeFile && file_exists($routeFile)) {
include $routeFile;
}
and
if (\CoasterCms\Helpers\Cms\Install::isComplete()) {
include __DIR__ . '/routes/admin.php';
include __DIR__ . '/routes/cms.php';
include base_path('/Modules/Test/Routes/web.php');
} else {
I know the routes are there because artisan route:list is showing them.
Every time I try to hit my page I get redirected back to the admin area. (I'm exploring and testing through the admin area).
if I comment out
// Route::any($adminUrl . '{other}', 'CoasterCms\Http\Controllers\AdminController')->where('other', '.*');
I get a 404 page.
Basically my routes file looks like:
$routeNamePrefix = 'coaster.admin.';
$adminUrl = config('coaster::admin.url') . '/';
// $adminController = '';
$nameSpace = 'Modules\Test\Http\Controllers';
Route::group(['prefix' => $adminUrl, 'middleware' => ['web', 'coaster.admin']], function () use ($adminUrl, $routeNamePrefix, $nameSpace) {
Route::get('test', ['uses' => $nameSpace . '\TestController', 'as' => $routeNamePrefix . 'system']);
});
My routes do work if I add them directly to the admin.php routes file.
$nameSpaceCore = 'Modules\Test\Http\Controllers';
Route::group(['prefix' => $adminUrl, 'middleware' => ['web', 'coaster.admin']], function () use ($adminUrl, $routeNamePrefix, $nameSpaceCore) {
Route::get('test', ['uses' => $nameSpaceCore . '\TestController', 'as' => $routeNamePrefix . 'system']);
});
But I really don't want to be editing your package routes like this.
I must be missing something, could you give me an idea or a heads up where to look next?
Thanks!
该提问来源于开源项目:CoasterCms/coastercms
- 点赞
- 回答
- 收藏
- 复制链接分享
8条回答
为你推荐
- 如何将Handle转换为HandleFunc?
- http
- 1个回答
- 使用Go 1.7解决供应商的“找不到包”错误
- it技术
- 互联网问答
- IT行业问题
- 计算机技术
- 编程语言问答
- 1个回答
- 通过多对多关系的Object字段从数据库中获取Object
- laravel
- mysql
- php
- 1个回答
- 对Lumen上的特定路由禁用CSRF TokenMismatch
- csrf
- laravel
- php
- 1个回答
- 带有参数的AJAX页面加载/ url导致空白页面
- ajax
- php
- jquery
- 1个回答
换一换