我遵循这个link
在laravel中创建项目hmvc
像我这样的结构文件
+ [app]
+ [Another Directory]
+ [modules]
+ [content]
+ [shop]
+ [controllers]
- ShopController.php
+ [view]
- home.blade.php
- route.php
- ServiceProvider.php
- ServiceProvider.php
+ [Another Directory]
这是我的shopController.php
<?php
namespace App\Modules\Shop\Controllers;
use App\Controllers\BaseController;
use View;
class ShopController extends BaseController {
public function showWelcome() {
return View::make('shop::home');
}
}
这是我在商店模块中的路线
<?php
Route::get('/shop', 'App\\Modules\\Shop\\Controllers\\ShopController@showWelcome');
我尝试从商店模块中的路线测试返回简单的hello字符串并且它正在工作
<?php
Route::get('admin/shop', function() {
return '<h1>Hello</h1>';
});
但我失踪了 所以无法在hmvc中显示路径或控制器的视图
@update Jan.J
商店模块中的路线
//this is working
Route::get('admin/shop', function() {
return '<h1>hello</h1>';
});
//this is working, result laravel default page hello in view mvc
// but i can't dispay view in shop module
Route::get('admin/shop', function() {
return View::make('hello');
});
//i try your script something like this, and it's not working
//correct me if i'm wrong
Route::get('/shop', 'new App\Modules\Shop\Controllers\ShopController(app('request'));');
@Update
我尝试更新我的店铺路线,以便像这样在商店模块中调用视图
<?php
Route::get('test/', function() {
return View::make(‘shop::home’);
});
它给出了结果
Class '‘shop' not found
任何想法?
答案 0 :(得分:1)
检查控制器类:
Route::get('/shop', function () {
$controller = new App\Modules\Shop\Controllers\ShopController(app('request'));
var_dump($controller);
});
有效吗?你看到班级转储吗?如果不是,则显示错误。