PHP code example of sinemacula / laravel-modules

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

    

sinemacula / laravel-modules example snippets


view('billing::invoices.show');
trans('billing::invoices.paid');



use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
use SineMacula\Laravel\Modules\Application;
use SineMacula\Laravel\Modules\Configuration\Modules;

Modules::setBasePath(dirname(__DIR__));

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        api      : Modules::routePaths(),
        health   : '/health',
        apiPrefix: '',
    )
    ->withMiddleware(function (Middleware $middleware): void {})
    ->withExceptions(function (Exceptions $exceptions): void {})
    ->create();

$routes = Modules::routePaths();

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: Arr::only($routes, ['storefront']),
        api: Arr::except($routes, ['storefront']),
    )

module_path();           // <base>/modules
module_path('Billing');  // <base>/modules/Billing

resource_path('billing::views');  // <base>/modules/Billing/Resources/views
bash
php artisan make:controller "App\Billing\Http\Controllers\StatementController"
php artisan make:model "App\Billing\Models\Invoice"
text
database/factories/
└── Billing/
    └── InvoiceFactory.php    # Database\Factories\Billing\InvoiceFactory
text
modules/Billing/
├── Console/
│   ├── Commands/
│   └── schedule.php
├── Http/
│   ├── Controllers/
│   ├── Requests/
│   └── routes.php
├── Listeners/
├── Models/
└── Resources/
    ├── lang/
    └── views/
bash
php artisan optimize        # Includes module:cache
php artisan optimize:clear  # Includes module:clear