PHP code example of erlandmuchasaj / laravel-modules

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

    

erlandmuchasaj / laravel-modules example snippets


    /**
     * Get the services provided by the provider.
     *
     * @var array<int, class-string>
     */
    protected array $providers = [
        ...
        NewServiceProvider::class, // <= new provider added here
    ];

    /**
     * Class event subscribers.
     *
     * @var array<int, class-string>
     */
    protected $subscribe = [
        AnnouncementEventListener::class
    ];

    /**
     * The event listener mappings for the application.
     *
     * @var array<class-string, array<int, class-string>>
     */
    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],
    ];

    /**
     * The policy mappings for the application.
     * Announcement::class is the model <==
     * 
     * @var array<class-string, class-string>
     */
    protected array $policies = [
        Announcement::class => AnnouncementPolicy::class,
    ];


    /**
     * The policy mappings for the application.
     * Announcement::class is the model <==
     * 
     * @var array<class-string, class-string>
     */
    protected array $policies = [
        Announcement::class => AnnouncementObserver::class,
    ];


    /**
     * The available command shortname.
     *
     * @var array<int, class-string>
     */
    protected array $commands = [
        AppVersion::class,
        SendAnnouncementNotifications::class
    ];

    /**
     * The application's global middleware stack.
     *
     * @var array<int, class-string>
     */
    protected array $middleware = [
        ...
        AddXHeader::class, // <== Add global middleware here
    ];

    /**
     * The application's route middleware groups.
     *
     * @var array<string, array<int, class-string>>
     */
    protected array $middlewareGroups = [
        'web' => [
            RememberLocale::class,
        ],
        'api' => [
            IdempotencyMiddleware::class,
        ],
        // <== Add grouped middleware here. you can add to existing group or create new groups.
    ];

    /**
     * The application's route middleware.
     * These middleware may be assigned to group or used individually.
     *
     * @var array<string, class-string>
     */
    protected array $routeMiddleware = [
        ...
        'ip_whitelist' => IpWhitelist::class, // <== Add route middleware here
    ];

shell
php artisan module:make <ModuleName>
bash
php artisan module:make <ModuleName>