Skip to content

Creating modules

Min De Sik edited this page Mar 25, 2017 · 1 revision

Modules in Mconsole are micro Laravel applications and have their own resources (controllers, routes, views, models, etc.). Mconsole installation requires only milax/mconsole-base-components package, wich have two modules News and Pages.

There are 3 module types:

  • base - module installed from package manager
  • custom - module created within laravel project
  • extended - module installed from package manager and extended by custom module

How to create new modules

To create new custom module install Mconsole and then call artisan command: php artisan make:module {ClassName} - this command will create module inside /app/Mconsole/ directory.

If you wish to extend base module (for example Pages or News) use module name as class name: php artisan make:module Page.

To develop module package run: php artisan make:module --package, this will create module in /workbench directory, set namespaces to Milax\Mconsole instead of App\Mconsole, and generates composer.json inside module directory.

Module structure

Here an example structure of module called Test:

└── Test
├── assets
│ ├── config
│ ├── migrations
│ ├── public
│ │ ├── css
│ │ ├── img
│ │ └── js
│ └── resources
│ ├── lang
│ │ ├── en
│ │ └── ru
│ └── views
├── bootstrap.php (required)
├── Http
│ ├── Controllers
│ │ └── TestController.php
│ └── routes.php
├── Installer.php
├── Models
└── Provider.php
  • bootstrap.php is required, it contains all module info
  • assets/public/\*/ you can store any assets structure, they all will be copied in /massets/modules/Test/*/ directory
  • Installer.php is optional file, usually we use it as settings seeder
  • Provider.php it's a Laravel Service Provider

Clone this wiki locally