PHP code example of salodev / modularize

1. Go to this page and download the library: Download salodev/modularize 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/ */

    

salodev / modularize example snippets




namespace App\Modules;

use Salodev\Modularize\Module;

class AppModule extends Module {

}

    public function register() {
        $this->provide(ChildModule::class);
    }

class UsersModule {
    public function bootApiRoutes() {
        $this->router()->get('', [UsersController::class, 'index']);

        // For api authorized requests
        $this->router()->middleware('auth:api')->group(function() {
            $this->router()->get('/me', [UsersController::class, 'me']);
        });
    }
}

    $this->routePrefix = 'my-route-prefix'

    // another case
    $this->routePrefix = '{account}' // for GET user/{account}

return [
    'api-key' => env('APP_SERVICE_API_KEY')
];

$apiKey = \App\Modules\Service\ServiceModule::config('api-key');

config('app.service.api-key');

    app\
        Modules\
            ModuleName\
                Commands\
                Mails\
                Migrations\
                Models\
                Requests\
                Resources\
                Views\
                ModuleNameController.php
                ModuleNameModule.php
            AppModule.php

app\
    Modules\
        AppModules.php
bash
php artisan list modularize
bash
php artisan modularize:make:module

php artisan modularize:add:route
bash
php artisan modularize:add:route --help
bash
php artisan modularize:make:migration
bash
php artisan migrate:status
bash
php artisan modularize:list:migrations

+------+-----------------------------------------+-----------------------------------+-------+
| Ran? | Migration                               | Directory                         | Batch |
+------+-----------------------------------------+-----------------------------------+-------+
| No   | 2023_01_21_122840_create_article_table  | /app/Modules/Articles/Migrations  |       |
| No   | 2023_01_21_165751_create_customer_table | /app/Modules/Customers/Migrations |       |
| No   | 2023_01_21_165843_create_sale_table     | /app/Modules/Sales/Migrations     |       |
+------+-----------------------------------------+-----------------------------------+-------+
bash
php artisan migrate
bash
app\
    Modules\
        Service\
            ServiceModule.php
            config.php        <-- here
        AppModule.php
bash
php artisan modularize:make:config