lassehaslev/laravel-modules
Use Package development in your local projects., (*1)
Structure your applications functionality into modules and autoload the packages ServiceProviders., (*2)
Install and Setup
- Run
composer require lassehaslev/laravel-modules
.
-
(Not needed in laravel 5.5) Add the following line to
providers
in config/app.php
LasseHaslev\LaravelModules\Providers\ServiceProvider::class,
-
Ok, this step is very important: Add the following to your projects composer.json.
If you do not, we cannot find out where your modules are loaded from., (*3)
"extra": {
...
"merge-plugin": {
"include": [
"Modules/*/composer.json"
],
"recurse": true,
"replace": false,
"merge-dev": true,
"merge-extra": false,
"merge-extra-deep": false
}
}
- Now, run
php artisan modules:make-folder
to create modules folder.
Discover packages
Run php artisan package:discover-modules
to find all packages., (*4)
This will discover vendor packages and package modules., (*5)
You should replace the discover function in composer to auto update every time you run a composer command., (*6)
"post-autoload-dump": [
...
"@php artisan package:discover-modules"
]
Remember to run this command every time you create a new module., (*7)
Create local packages
I recommend you to use LasseHaslev/laravel-package-template to get a flying start to your local package., (*8)
Go to LasseHaslev/laravel-package-template quick package setup., (*9)
Configuration
If you deside to change the place where your modules lives you must change path in composer.json extra.merge-plugin.include
., (*10)
You must also overwrite the config for modules
Config::set( 'modules.path', base_dir( 'your/new/path' ) )
, (*11)
Development
``` bash, (*12)
Install dependencies
composer install, (*13)
Install for running automatic tests
yarn, (*14)
Make Modules folders in orcestra to make tests work
mkdir vendor/orchestra/testbench-core/laravel/Modules, (*15)
Run one time
npm run test, (*16)
Automaticly run test on changes
npm run dev
```, (*17)