I'm currently creating a modular laravel project here was my reference link
Creating a Modular Application in Laravel
Right now I want to create a module folder same directory with my app folder
I also create a 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()
{
//
}
}
I added the ModulerServiceProvider class to my
config/app.php
providers' => [
App\Providers\ModuleServiceProvider::class,
]
and here is the route under modules/yinyang/route.php being added
Route::group(['prefix' => 'yinyang', 'namespace' => 'Modules\Yinyang\Controllers'], function () {
Route::get('/', 'GameController@index');
});
Here is the modules/yinyang/controller/GameController.php
namespace Modules\Yinyang\Controllers;
use App\Http\Controllers;
class GameController extends Controller {
public function __construct() {
}
public function index() {
}
}
And Here is the problem when i am trying to access already the route under yinyang module http://192.168.200.30/try/sample/public/yinyang
Class Modules\Yinyang\Controllers\GameController does not exist
Anyone has any advice/suggestion on how to solve this problem. Thanks.