0
我目前正在創建一個模塊化laravel項目在這裏被我引用鏈接創建於Laravel 5.2模塊外應用
Creating a Modular Application in Laravel
現在我想創建一個文件夾模塊相同的目錄與我的app文件夾
我也創建了ModuleServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class ModuleServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
$modules = config('modules');
if (ENVIRONMENT != 'local') {
} else {
foreach ($modules as $key => $module) {
// Load the routes for each of the modules
if(file_exists(__DIR__ . "../../../modules/{$module}/routes.php")) {
require __DIR__ . "../../../modules/{$module}/routes.php";
} else {
echo "{$module} Module Not found"; die;
}
// Load the views
if(is_dir(__DIR__ . "../../../modules/{$module}/views")) {
$this->loadViewsFrom(__DIR__ . "../../../modules/{$module}/views", $module);
} else {
echo "{$module} Module View Not found"; die;
}
}
}
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
//
}
}
我加入了ModulerServiceProvider類我
配置/ app.php
providers' => [
App\Providers\ModuleServiceProvider::class,
]
,這裏是被添加
Route::group(['prefix' => 'yinyang', 'namespace' => 'Modules\Yinyang\Controllers'], function() {
Route::get('/', '[email protected]');
});
這裏是下模塊/陰陽/ route.php路線模塊/ yinyang /控制器/ GameController.php
namespace Modules\Yinyang\Controllers;
use App\Http\Controllers;
class GameController extends Controller {
public function __construct() {
}
public function index() {
}
}
而且這裏的問題是,當我嘗試在陰陽模塊已經訪問路線http://192.168.200.30/try/sample/public/yinyang
Class Modules\Yinyang\Controllers\GameController does not exist
任何人有關於如何解決這個問題的任何意見/建議。謝謝。