PHP code example of dev-sajid / laravel-modular

1. Go to this page and download the library: Download dev-sajid/laravel-modular library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dev-sajid / laravel-modular example snippets




return [
    // Directory where modules are stored
    'modules_path' => 'modules',

    // Base namespace for modules
    'namespace' => 'Modules',

    // Whether to prefer module-specific ServiceProviders
    'prefer_module_provider' => true,
];



namespace Modules\Blog\Http\Controllers;

use Illuminate\Routing\Controller;

class BlogController extends Controller
{
    public function index()
    {
        return view('blog::index');
    }
}
bash
   php artisan make:module Blog
   

   modules/
   └── Blog/
       ├── BlogServiceProvider.php
       ├── Http/
       │   └── Controllers/
       │       └── BlogController.php
       ├── routes/
       │   └── web.php
       ├── resources/
       │   └── views/
       │       └── index.blade.php
       ├── Database/
       │   └── migrations/
       │       └── 2025_08_24_000000_create_blogs_table.php
       └── lang/
   
bash
   php artisan migrate
   
bash
php artisan vendor:publish --tag=modular-config
bash
php artisan make:module Blog