PHPackages                             codeurx/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. codeurx/modular

ActiveLibrary

codeurx/modular
===============

Codeurx Modular is simply a package for Laravel to help you create and manage modules.

v2.1(6y ago)0128MITPHPPHP &gt;=7.1CI failing

Since Dec 12Pushed 6y ago1 watchersCompare

[ Source](https://github.com/codeurx/modular)[ Packagist](https://packagist.org/packages/codeurx/modular)[ RSS](/packages/codeurx-modular/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (3)Versions (6)Used By (0)

Codeurx Modular
===============

[](#codeurx-modular)

[![License](https://camo.githubusercontent.com/21eafecd7ed30ed5178042a53f77b88d15fa75eedfba11007a862d9e45eb094f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f636f64657572782f6d6f64756c61722e737667)](https://packagist.org/packages/codeurx/modular)[![Build Status](https://camo.githubusercontent.com/ee8818efa965f171b6092ceb836f8d5163130cce93011d6016b8a7f28352617d/68747470733a2f2f7472617669732d63692e6f72672f636f64657572782f6d6f64756c61722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/codeurx/modular)[![Latest Stable Version](https://camo.githubusercontent.com/e3bcbe641321f5e443ab9494b34c014b514bbbc622dbd9b5ffa6a1e0883be166/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f64657572782f6d6f64756c61722e737667)](https://packagist.org/packages/codeurx/modular)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/afe1a7248778740627ace06589f2f0eea7cfbf646648d3b42c99a8c90590716c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636f64657572782f6d6f64756c61722f6261646765732f7175616c6974792d73636f72652e706e673f623d76322e32)](https://packagist.org/packages/codeurx/modular)

Codeurx Modular is simply a package for Laravel to help you create and manage modules.

Install
-------

[](#install)

To install through Composer, by run the following command:

```
composer require codeurx/modular
```

### Autoloading

[](#autoloading)

By default the module classes are not loaded automatically. You can autoload your modules using `psr-4`. For example:

```
{
  "autoload": {
    "psr-4": {
      "App\\": "app/",
      "App\\Modules\\": "app/Modules/"
    },
    "files": [
        "app/Modules/helpers/helpers.php"
    ]
  }
}
```

**Tip: don't forget to run `composer dump-autoload` afterwards.**

run the following command to publish `modules` table migrations:

```
php artisan vendor:publish --provider="Codeurx\Modular\ModularServiceProvider" --tag="migrations"

```

after that run the command:

```
php artisan migrate

```

Usage
-----

[](#usage)

**Creating A Module**

To create a new module, simply run the following command:

```
php artisan modular:make
```

- `` - Replace with the name of the desired module.

**Folder Structure**

```
app/Modules/
      ├── Users/
          ├─ Database/
             ├─ Migrations/
          ├─ Http/
             ├─ Controllers/
                ├─ UsersController.php
             ├─ Models/
                ├─ UsersModel.php
          ├─ Providers/
             ├─ UsersServiceProvider.php
          ├─ Resources/
             ├─ views/
                ├─ index.blade.php
          ├─ Routes/
             ├─ web.php

```

You can access the url example for Users module by typing :

```
http://sever/users/ or  http://sever/public/users/

```

For Dummy data:

```
http://sever/users/users-test or  http://sever/public/users/users-test

```

**Deleting A Module**

To delete a specific module, simply run the following command:

```
php artisan modular:delete
```

- `` - Replace with the name of the desired module to be deleted.

**Tip: if the module does not exist you will be asked if you want to create it.**

**Listing All the Modules**

To list the modules just run the following command:

```
php artisan modular:list
```

**Creating A Module Migration**

To create a migration for a specific module just run the following command:

```
php artisan modular:make-migration  --table=
```

- `` - Replace with the name of the desired module.
- `` - optional field, replace it with a disired name of table.

**if you don't give the option --table the table name will take the name of the module by default.**

**Migrating Database for all modules**

```
php artisan modular:migrate
```

**Migrating Database for specific module**

```
php artisan modular:migrate
```

**Creating a new Controller for specific module**

```
php artisan modular:make-controller
```

- `` - Replace with the name of the desired module.
- `` - Replace with the controller name.

For example :

```
  php artisan modular:make-controller users TestController
```

or

```
  php artisan modular:make-controller users Test/TestController
```

**Tip: if you typed the second command the folder structure will be like below :**

```
app/Modules/
      ├── Users/
          ├─ Database/
             ├─ Migrations/
          ├─ Http/
             ├─ Controllers/
                ├─ Test
                   ├─ TestController.php
                ├─ UsersController.php
             ├─ Models/
                ├─ UsersModel.php
          ├─ Providers/
             ├─ UsersServiceProvider.php
          ├─ Resources/
             ├─ views/
                ├─ index.blade.php
          ├─ Routes/
             ├─ web.php

```

And for the routes you should add a line like this :

```
