Napp Core Service Provider registers module dependencies.
Each module must register a ServiceProvider extending the Napp\Core\Module\Provider\CoreServiceProvider. Example:
<?phpnamespaceNapp\Forms;
useNapp\Forms\Event\FormWasSubmittedEvent;
useNapp\Forms\Listener\SendFormSubmissionEmailListener;
useNapp\Forms\Model\Form;
useNapp\Forms\Observer\FormObserver;
useNapp\Forms\Repository\FormsRepository;
useNapp\Forms\Repository\FormsRepositoryInterface;
useNapp\Core\Module\Provider\CoreServiceProvider;
class FormsServiceProvider extends CoreServiceProvider
{
protected$routeNamespace = 'Napp\Forms';
publicconstEXTENSION_FORM_BUILDER = 'extension.form_builder';
publicconstFEATURE_ALLOW_SOMETHING = 'feature.form_allow_something';
protected$repositories = [
FormsRepositoryInterface::class => FormsRepository::class
];
protected$features = [
self::FEATURE_ALLOW_SOMETHING => [
'translation_key',
true// boolean true if the feature has settings
],
self::FEATURE_ALLOW_SOMETHING => 'translation_key' ];
protected$events = [
FormWasSubmittedEvent::class => SendFormSubmissionEmailListener::class
];
protected$permissions = [
'forms.view',
'forms.create',
'forms.update',
'forms.delete',
'forms.duplicate',
'forms.entries'
];
protected$observers = [
Form::class => FormObserver::class
];
protected$extensions = [
self::EXTENSION_FORMS => 'extensions.forms'
];
protectedfunctiongetCMSRoutes()
{
return__DIR__ . '/routes/cms.php';
}
protectedfunctiongetApiRoutes()
{
return__DIR__ . '/routes/api.php';
}
protectedfunctiongetFrontRoutes()
{
return__DIR__ . '/routes/front.php';
}
protectedfunctiongetFrontApiRoutes()
{
return__DIR__ . '/routes/frontApi.php';
}
}At Napp we dont follow the default Laravel folder structure. We use Domain structure - so everything related to Products is within the Napp\MyModule\Products namespace.
module-project/
config/
database/
|-- factories/
|-- migrations/
|-- seeds/
routes/
src/
|-- Products/
|-- Console/
|-- Controller/
|-- Event/
|-- Exception/
|-- Factory/
|-- Listener/
|-- Model/
|-- Middleware/
|-- Notification/
|-- Policy/
|-- Repository/
|-- Request/
|-- Transformer/
|-- Orders/
|-- Controller/
|-- Model/
|-- Repository/
|-- Request/
|-- Transformer/
MyModuleServiceProviders.php
helpers.php
resources/
|-- lang/
|-- views/
tests/
.gitattributes
.gitignore
.gitlab-ci.yml
composer.json
LICENSE.md
phpunit.xml
README.md