Package Data | |
---|---|
Maintainer Username: | stevenwadejr |
Maintainer Contact: | stevenwadejr@gmail.com (Steven Wade) |
Package Create Date: | 2014-01-15 |
Package Last Update: | 2014-11-10 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:03:24 |
Package Statistics | |
---|---|
Total Downloads: | 26,044 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 5 |
Total Watchers: | 14 |
Total Forks: | 1 |
Total Open Issues: | 0 |
The Modular Laravel allows for Laravel code to be organized in smaller sets within an application.
Via Composer
{
"require": {
"suitetea/modularlaravel": "0.5.*"
}
}
Next run an update from Composer
composer update
After installation is complete, add the service provider to the app/config/app.php
providers array.
SuiteTea\ModularLaravel\ModularLaravelServiceProvider
Modules are self contained packages that can be installed via Composer or instantiated manually.
Modules follow the PSR-4 package structure and should adhere to its standards.
Modules need to register with ModularLaravel. Example registration with available configuration is below:
ModularLaravel::register([
'name' => 'attachments',
'directory' => 'app/modules/attachments',
'requires' => [
'uploader',
'file_system'
],
'namespace' => 'Modules\Attachments',
'autoload' => [
'files' => [
'routes.php'
],
'classmap' => [
'controllers'
]
]
]);
You can pre-register a module before ModularLaravel is instantiated. This is useful when a module is installed via Composer. You can autoload a file, pre-register the module, and when Laravel is booted, the module will attempt activation.
use SuiteTea\ModularLaravel\Manager;
Manager::preRegister([
'name' => 'attachments',
'directory' => 'app/modules/attachments',
'requires' => [
'uploader',
'file_system'
],
'namespace' => 'Modules\Attachments',
'autoload' => [
'files' => [
'routes.php'
],
'classmap' => [
'controllers'
]
]
]);
__DIR__
can be used as a shortcut)files
will include any files in this array. classmap
will add these directories to the class autoloader.ModularLaravel fires two types of events when booting.
"modules.active attachments"
.modules.active
event, this event appends the module name to the end of the event, ex: "modules.activation_failed attachments"
.A module can include a views
directory. ModuleLaravel registers a view namespace equal to the name of the module. This is helpful when referring to a specific module's views.
Example: a view file called upload.blade.php
would be referrenced like so - `View::make('attachments::upload');
A module may include configuration files within a config
directory within the module directory. ModularLaravel registers a config namespace equal to the name of the module all lowercase.
Example: a config file located at config/config.php
in the module directory would be accessible via Config::('modulename::configitem')
. Likewise, a config file not using the default name of config.php
can be accessed via dot notation: Config::('modulename::file.option')
===
Todo: