PHPackages                             dnafactory/laravel-modular - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. dnafactory/laravel-modular

ActiveLibrary[Framework](/categories/framework)

dnafactory/laravel-modular
==========================

Transform laravel in a modular system

1.4.1(6y ago)0371MITPHPPHP &gt;=7.0.0

Since Mar 18Pushed 5y ago1 watchersCompare

[ Source](https://github.com/dnafactory/laravel-modular)[ Packagist](https://packagist.org/packages/dnafactory/laravel-modular)[ Docs](https://github.com/danielrussob/laravel-modular.git)[ RSS](/packages/dnafactory-laravel-modular/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (13)Used By (1)

Transform laravel in a modular system
=====================================

[](#transform-laravel-in-a-modular-system)

Usage
-----

[](#usage)

Install

`composer require dnafactory/laravel-modular`

Create a folder Modules under app

\-----&gt; app/Modules

That's it!

Create a Module
---------------

[](#create-a-module)

Create a folder under Modules

ex.: app/Modules/Module1

that's it!

Module structure
----------------

[](#module-structure)

```
app
├── Modules
├────── Module1
├──────────── Api
├───────────────── Data
├───────────────────── OneInterface.php
├───────────────────── TwoInterface.php
├───────────────── OneRepositoryInterface.php
├───────────────── TwoManagementInterface.php
├──────────── Channel
├───────────────── OneChannel.php
├───────────────── TwoChannel.php
├──────────── Command
├───────────────── OneCommand.php
├───────────────── TwoCommand.php
├──────────── configs
├───────────────── one.php
├───────────────── two.php
├───────────────── three.php
├───────────────── foldername
├───────────────────── four.php
├──────────── Controller
├───────────────── OneController.php
├───────────────── TwoController.php
├──────────── Management
├───────────────── OneManagement.php
├───────────────── TwoManagement.php
├──────────── etc
├───────────────── commands.php
├───────────────── di.php
├───────────────── providers.php
├──────────── Event
├───────────────── OneEvent.php
├───────────────── TwoEvent.php
├───────────────── ThreeEvent.php
├──────────── factories
├───────────────── One.php
├───────────────── Two.php
├───────────────── Three.php
├──────────── Factory
├───────────────── OneFactory.php
├───────────────── TwoFactory.php
├───────────────── ThreeFactory.php
├──────────── Management
├───────────────── OneManagement.php
├───────────────── TwoManagement.php
├───────────────── ThreeManagement.php
├──────────── Middleware
├───────────────── OneMiddleware.php
├───────────────── TwoMiddleware.php
├───────────────── ThreeMiddleware.php
├──────────── migrations
├───────────────── 2000_00_00_000010_create_first_table.php
├───────────────── 2000_00_00_000020_create_second_table.php
├──────────── Model
├───────────────── One.php
├───────────────── Two.php
├───────────────── Three.php
├──────────── Provider
├───────────────── OneServiceProvider.php
├───────────────── TwoServiceProvider.php
├───────────────── ThreeServiceProvider.php
├──────────── Queue
├───────────────── OnePublisher.php
├───────────────── OneConsumer.php
├──────────── Repository
├───────────────── OneRepository.php
├───────────────── TwoRepository.php
├──────────── routes
├───────────────── api.php
├───────────────── web.php
├──────────── Seed
├───────────────── OneSeeder.php
├───────────────── TwoSeeder.php
├──────────── views
├───────────────── first.blade.php
├───────────────── second.blade.php
├──────────── helpers.php
├──────────── routes.php
├────── Module2
├──────────── ...
├──────────── ...
├────── Module3
├──────────── ...
├──────────── ...

```

### Api folder

[](#api-folder)

All files in this folder are Service Contract's file of: Facade, Proxy, Mediator, Strategy or generic Service

All files are interface

Don't forget to register this class in etc/di.php

*Be careful*: Api has first letter in uppercase and singular

### Api/Data folder

[](#apidata-folder)

All files in this folder are Service Contract's file of: Model or generic Data Class

All files are interface

Don't forget to register this class in etc/di.php

*Be careful*: Data has first letter in uppercase and singular

### Channel folder

[](#channel-folder)

All files in this folder are Event Channel

*Be careful*: Channel has first letter in uppercase and singular

### Command folder

[](#command-folder)

All files in this folder are Console Command

*Be careful*: Command has first letter in uppercase and singular

### configs folder

[](#configs-folder)

All files in this folder will be consider configs

You can refer to it as config('MODULENAME.FILENAME') or config('MODULENAME.FOLDER.FILENAME')

ex.:

```
config('module1.one');
```

```
config('module1.foldername.four');
```

*Be careful*: configs are lowercase and plural

### Controller folder

[](#controller-folder)

All files in this folder are Controller

All files must terminate with Controller word

*Be careful*: Controller has first letter in uppercase and singular

### etc folder

[](#etc-folder)

There's some defined configuration in this folder

#### di.php

[](#diphp)

di.php are an array of di in module

```
