PHP code example of sebastiaanluca / laravel-module-loader
1. Go to this page and download the library: Download sebastiaanluca/laravel-module-loader 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/ */
sebastiaanluca / laravel-module-loader example snippets
declare(strict_types=1);
namespace MyModule\Providers;
use SebastiaanLuca\Module\Providers\ModuleProvider;
class MyModuleServiceProvider extends ModuleProvider
{
/**
* Register the application services.
*
* @return void
*/
public function register() : void
{
parent::register();
}
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot() : void
{
parent::boot();
}
}
declare(strict_types=1);
namespace MyModule\Providers;
use MyModule\Models\Item;
use MyModule\Models\ShoppingCart;
use SebastiaanLuca\Module\Providers\ModuleProvider;
class MyModuleServiceProvider extends ModuleProvider
{
/**
* The polymorphic models to map to their alias.
*
* @var array
*/
protected $morphMap = [
'item' => Item::class,
'shopping_cart' => ShoppingCart::class,
];
}
declare(strict_types=1);
namespace MyModule\Providers;
use MyModule\Listeners\UpdateUserInfo;
use MyModule\Listeners\UserEventSubscriber;
use SebastiaanLuca\Module\Providers\ModuleProvider;
use Users\Events\UserCreated;
class MyModuleServiceProvider extends ModuleProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
UserCreated::class => [
UpdateUserInfo::class,
]
];
/**
* The subscriber classes to register.
*
* @var array
*/
protected $subscribe = [
UserEventSubscriber::class,
];
}
declare(strict_types=1);
namespace MyModule\Providers;
use MyModule\Http\Routers\UserAuthRouter;
use MyModule\Http\Routers\UserDashboardRouter;
use SebastiaanLuca\Module\Providers\ModuleProvider;
class MyModuleServiceProvider extends ModuleProvider
{
/**
* The routers to be automatically mapped.
*
* @var array
*/
protected $routers = [
UserAuthRouter::class,
UserDashboardRouter::class,
];
}
declare(strict_types=1);
namespace MyModule\Providers;
use MyModule\Providers\ModuleEventProvider;
use MyModule\Providers\ModuleRouteProvider;
use SebastiaanLuca\Module\Providers\ModuleProvider;
class MyModuleServiceProvider extends ModuleProvider
{
/**
* The additional providers to register.
*
* @var array
*/
protected $providers = [
ModuleEventProvider::class,
ModuleRouteProvider::class,
];
}