konekt/concord
Laravel extension for building modular applications using conventions on top of service providers. Manage in-app and external modules with isolation-friendly structure, version compatibility across Laravel releases, and tooling around module registration and organization.
Compared to Modules there's not much sense to create an in-app box, even if it's technically possible. The reason is that a Box can be considered an application boilerplate, so why define a template and immediately overwrite it? Your application is responsible for everything an in-app Box would do.
Init a git repo in an empty folder: git init .
Add composer.json:
{
"name": "vendor/mybox",
"description": "My Box Rulez",
"type": "library",
"require": {
"php": ">=7.0.0",
"konekt/concord": ">=0.9.10"
},
"autoload": {
"psr-4": { "Vendor\\MyBox\\": "src/" }
}
}
Create the file src/Providers/ModuleServiceProvider.php:
namespace Vendor\MyBox\Providers;
use Konekt\Concord\BaseBoxServiceProvider;
class ModuleServiceProvider extends BaseBoxServiceProvider
{
}
Create src/resources/manifest.php:
<?php
return [
'name' => 'My Box',
'version' => '1.0.0'
];
Commit all the stuff, and publish it (github and packagist if it's open source)
Boxes have their primary config file located in resources/config/box.php.
Modules need to be added here:
<?php
return [
'modules' => [
Vendor\MyModule\Providers\ModuleServiceProvider::class => [],
Vendor\AnotherModule\Providers\ModuleServiceProvider::class => []
]
];
The empty arrays in the example mean that everything from those modules will be imported according to the defaults.
You may decide to gather/modify/skip migrations from the underlying modules. In this case you can suppress migrations provided by the module:
<?php
return [
'modules' => [
Vendor\MyModule\Providers\ModuleServiceProvider::class => [
'migrations' => false
],
Vendor\AnotherModule\Providers\ModuleServiceProvider::class => [
'migrations' => false
]
]
];
See also: Box Configuration and Turn Migrations On/Off
!> Make sure to provide a compatible replacement if you're suppressing a module's migration.
In the laravel application: composer require vendor/mybox
Add the module to config/concord.php:
<?php
return [
'modules' => [
Vendor\MyBox\Providers\ModuleServiceProvider::class,
]
];
Next: Configuration »
How can I help you explore Laravel packages today?