Create A Module
Creating An In-app Module
-
Create the module folder
app/Modules/Demo
-
Create the file
app/Modules/Demo/Providers/ModuleServiceProvider.php
:namespace App\Modules\Demo\Providers; use Konekt\Concord\AbstractModuleServiceProvider; class ModuleServiceProvider extends AbstractModuleServiceProvider { }
-
Create
app/Modules/Demo/resources/manifest.php
:<?php return [ 'name' => 'Demo App Module', 'version' => '1.3.9' ];
-
Add the module to
config/concord.php
:<?php return [ 'modules' => [ App\Modules\Demo\Providers\ModuleServiceProvider::class, ] ];
Now if you run the php artisan concord:modules
command it shows the newly added module:
+----+------------------+--------+---------+------+-------------------+
| # | Name | Kind | Version | Id | Namespace |
+----+------------------+--------+---------+------+-------------------+
| 1. | Demo App Module | Module | 1.3.9 | demo | App\Modules\Demo |
+----+------------------+--------+---------+------+-------------------+
Creating An External Module (With Git And Composer)
-
Init a git repo in an empty folder:
git init .
-
Add composer.json:
{ "name": "vendor/mymodule", "description": "My Module Rulez", "type": "library", "require": { "php": ">=7.0.0", "konekt/concord": ">=0.9.10" }, "autoload": { "psr-4": { "Vendor\\MyModule\\": "src/" } } }
-
Create the file
src/Providers/ModuleServiceProvider.php
:namespace Vendor\MyModule\Providers; use Konekt\Concord\BaseModuleServiceProvider; class ModuleServiceProvider extends BaseModuleServiceProvider { }
-
Create
src/resources/manifest.php
:<?php return [ 'name' => 'My Module', 'version' => '1.0.0' ];
-
Commit all the stuff, and publish it (github and packagist if it's open source)
-
In the host application:
composer require vendor/mymodule
-
Add the module to
config/concord.php
:<?php return [ 'modules' => [ Vendor\MyModule\Providers\ModuleServiceProvider::class, ] ];
You're done.
Next: Boxes Explained »