{"id":18829804,"url":"https://github.com/froiden/laravel-modules","last_synced_at":"2025-10-30T23:23:07.577Z","repository":{"id":77323402,"uuid":"81419799","full_name":"Froiden/laravel-modules","owner":"Froiden","description":"Copied from nwidart/laravel-modules to use Froiden/laravel-rest-api","archived":false,"fork":false,"pushed_at":"2017-04-17T07:16:20.000Z","size":203,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-12-30T06:27:16.274Z","etag":null,"topics":["rest-api"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Froiden.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-09T06:57:05.000Z","updated_at":"2021-01-28T11:33:51.000Z","dependencies_parsed_at":"2023-02-24T21:15:13.453Z","dependency_job_id":null,"html_url":"https://github.com/Froiden/laravel-modules","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Froiden%2Flaravel-modules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Froiden%2Flaravel-modules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Froiden%2Flaravel-modules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Froiden%2Flaravel-modules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Froiden","download_url":"https://codeload.github.com/Froiden/laravel-modules/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239765439,"owners_count":19693135,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rest-api"],"created_at":"2024-11-08T01:46:27.138Z","updated_at":"2025-10-30T23:23:02.541Z","avatar_url":"https://github.com/Froiden.png","language":"PHP","readme":"# Laravel-Modules\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/nwidart/laravel-modules.svg?style=flat-square)](https://packagist.org/packages/nwidart/laravel-modules)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Build Status](https://img.shields.io/travis/nWidart/laravel-modules/master.svg?style=flat-square)](https://travis-ci.org/nWidart/laravel-modules)\n[![Scrutinizer Coverage](https://img.shields.io/scrutinizer/coverage/g/nWidart/laravel-modules.svg?maxAge=86400\u0026style=flat-square)](https://scrutinizer-ci.com/g/nWidart/laravel-modules/?branch=master)\n[![SensioLabsInsight](https://img.shields.io/sensiolabs/i/25320a08-8af4-475e-a23e-3321f55bf8d2.svg?style=flat-square)](https://insight.sensiolabs.com/projects/25320a08-8af4-475e-a23e-3321f55bf8d2)\n[![Quality Score](https://img.shields.io/scrutinizer/g/nWidart/laravel-modules.svg?style=flat-square)](https://scrutinizer-ci.com/g/nWidart/laravel-modules)\n[![Total Downloads](https://img.shields.io/packagist/dt/nwidart/laravel-modules.svg?style=flat-square)](https://packagist.org/packages/nwidart/laravel-modules)\n\n\n- [Upgrade Guide](#upgrade-guide)\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Naming Convension](#naming-convension)\n- [Folder Structure](#folder-structure)\n- [Creating Module](#creating-a-module)\n- [Artisan Commands](#artisan-commands)\n- [Facades](#facades)\n- [Entity](#entity)\n- [Auto Scan Vendor Directory](#auto-scan-vendor-directory)\n- [Publishing Modules](#publishing-modules)\n\nThis is the copy of `nwidart/laravel-modules` is a laravel package which created to manage your large laravel app using modules. Module is like a laravel package, it has some views, controllers or models. This package is supported and tested in Laravel 5.\nWe have modified to use for our personal usage. We have modified such that when creating the new modules.\nIt creates controller,models, observers, migration according to `Froiden/laravel-rest-api` plugin\n\nThis package is a re-published, re-organised and maintained version of [pingpong/modules](https://github.com/pingpong-labs/modules), which isn't maintained anymore. This package is used in [AsgardCMS](https://asgardcms.com/).\n\nWith one big added bonus that the original package didn't have: **tests**.\n\nFind out why you should use this package in the article: [Writing modular applications with laravel-modules](https://nicolaswidart.com/blog/writing-modular-applications-with-laravel-modules).\n\n\u003ca name=\"upgrade-guide\"\u003e\u003c/a\u003e\n## Upgrade Guide\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n## Installation\n\n### Quick\n\nTo install through composer, simply run the following command:\n\n``` bash\ncomposer require nwidart/laravel-modules\n```\n\n#### Add Service Provider\n\nNext add the following service provider in `config/app.php`.\n\n```php\n'providers' =\u003e [\n  Nwidart\\Modules\\LaravelModulesServiceProvider::class,\n],\n```\n\nNext, add the following aliases to `aliases` array in the same file.\n\n```php\n'aliases' =\u003e [\n  'Module' =\u003e Nwidart\\Modules\\Facades\\Module::class,\n],\n```\n\nNext publish the package's configuration file by running :\n\n```\nphp artisan vendor:publish --provider=\"Nwidart\\Modules\\LaravelModulesServiceProvider\"\n```\n\n#### Autoloading\n\nBy default controllers, entities or repositories are not loaded automatically. You can autoload your modules using `psr-4`. For example :\n\n```json\n{\n  \"autoload\": {\n    \"psr-4\": {\n      \"App\\\\\": \"app/\",\n      \"Modules\\\\\": \"Modules/\"\n    }\n  }\n}\n```\n\n\u003ca name=\"configuration\"\u003e\u003c/a\u003e\n## Configuration\n\n- `modules` - Used for save the generated modules.\n- `assets` - Used for save the modules's assets from each modules.\n- `migration` - Used for save the modules's migrations if you publish the modules's migrations.\n- `generator` - Used for generate modules folders.\n- `scan` - Used for allow to scan other folders.\n- `enabled` - If `true`, the package will scan other paths. By default the value is `false`\n- `paths` - The list of path which can scanned automatically by the package.\n- `composer`\n- `vendor` - Composer vendor name.\n- `author.name` - Composer author name.\n- `author.email` - Composer author email.\n- `cache`\n- `enabled` - If `true`, the scanned modules (all modules) will cached automatically. By default the value is `false`\n- `key` - The name of cache.\n- `lifetime` - Lifetime of cache.\n\n\u003ca name=\"creating-a-module\"\u003e\u003c/a\u003e\n## Creating A Module\n\nTo create a new module you can simply run :\n\n```\nphp artisan module:make \u003cmodule-name\u003e\n```\n\n- `\u003cmodule-name\u003e` - Required. The name of module will be created.\n\n**Create a new module**\n\n```\nphp artisan module:make Blog\n```\n\n**Create multiple modules**\n\n```\nphp artisan module:make Blog User Auth\n```\n\nBy default if you create a new module, that will add some resources like controller, seed class or provider automatically. If you don't want these, you can add `--plain` flag, to generate a plain module.\n\n```shell\nphp artisan module:make Blog --plain\n#OR\nphp artisan module:make Blog -p\n```\n\n\u003ca name=\"naming-convension\"\u003e\u003c/a\u003e\n**Naming Convension**\n\nBecause we are autoloading the modules using `psr-4`, we strongly recommend using `StudlyCase` convension.\n\n\u003ca name=\"folder-structure\"\u003e\u003c/a\u003e\n**Folder Structure**\n\n```\nlaravel-app/\napp/\nbootstrap/\nvendor/\nModules/\n  ├── Blog/\n      ├── Assets/\n      ├── Config/\n      ├── Console/\n      ├── Database/\n          ├── Migrations/\n          ├── Seeders/\n      ├── Entities/\n      ├── Http/\n          ├── Controllers/\n          ├── Middleware/\n          ├── Requests/\n          ├── routes.php\n      ├── Providers/\n          ├── BlogServiceProvider.php\n      ├── Resources/\n          ├── lang/\n          ├── views/\n      ├── Repositories/\n      ├── Tests/\n      ├── composer.json\n      ├── module.json\n      ├── start.php\n```\n\n\u003ca name=\"artisan-commands\"\u003e\u003c/a\u003e\n## Artisan Commands\n\nCreate new module.\n\n```\nphp artisan module:make blog\n```\n\nUse the specified module.\n\n```php\nphp artisan module:use blog\n```\n\nShow all modules in command line.\n\n```\nphp artisan module:list\n```\n\nCreate new command for the specified module.\n\n```\nphp artisan module:make-command CustomCommand blog\n\nphp artisan module:make-command CustomCommand --command=custom:command blog\n\nphp artisan module:make-command CustomCommand --namespace=Modules\\Blog\\Commands blog\n```\n\nCreate new migration for the specified module.\n\n```\nphp artisan module:make-migration create_users_table blog\n\nphp artisan module:make-migration create_users_table --fields=\"username:string, password:string\" blog\n\nphp artisan module:make-migration add_email_to_users_table --fields=\"email:string:unique\" blog\n\nphp artisan module:make-migration remove_email_from_users_table --fields=\"email:string:unique\" blog\n\nphp artisan module:make-migration drop_users_table blog\n```\n\nRollback, Reset and Refresh The Modules Migrations.\n\n```\nphp artisan module:migrate-rollback\n\nphp artisan module:migrate-reset\n\nphp artisan module:migrate-refresh\n```\n\nRollback, Reset and Refresh The Migrations for the specified module.\n\n```\nphp artisan module:migrate-rollback blog\n\nphp artisan module:migrate-reset blog\n\nphp artisan module:migrate-refresh blog\n```\n\nCreate new seed for the specified module.\n\n```\nphp artisan module:make-seed users blog\n```\n\nMigrate from the specified module.\n\n```\nphp artisan module:migrate blog\n```\n\nMigrate from all modules.\n\n```\nphp artisan module:migrate\n```\n\nSeed from the specified module.\n\n```\nphp artisan module:seed blog\n```\n\nSeed from all modules.\n\n```\nphp artisan module:seed\n```\n\nCreate new controller for the specified module.\n\n```\nphp artisan module:make-controller SiteController blog\n```\n\nPublish assets from the specified module to public directory.\n\n```\nphp artisan module:publish blog\n```\n\nPublish assets from all modules to public directory.\n\n```\nphp artisan module:publish\n```\n\nCreate new model for the specified module.\n\n```\nphp artisan module:make-model User blog\n\nphp artisan module:make-model User blog --fillable=\"username,email,password\"\n```\n\nCreate new service provider for the specified module.\n\n```\nphp artisan module:make-provider MyServiceProvider blog\n```\n\nPublish migration for the specified module or for all modules.\n\nThis helpful when you want to rollback the migrations. You can also run `php artisan migrate` instead of `php artisan module:migrate` command for migrate the migrations.\n\nFor the specified module.\n\n```\nphp artisan module:publish-migration blog\n```\n\nFor all modules.\n\n```\nphp artisan module:publish-migration\n```\n\nPublish Module configuration files\n\n```\nphp artisan module:publish-config \u003cmodule-name\u003e\n```\n\n- (optional) `module-name`: The name of the module to publish configuration. Leaving blank will publish all modules.\n- (optional) `--force`: To force the publishing, overwriting already published files\n\nEnable the specified module.\n\n\n```\nphp artisan module:enable blog\n```\n\nDisable the specified module.\n\n```\nphp artisan module:disable blog\n```\n\nGenerate new middleware class.\n\n```\nphp artisan module:make-middleware Auth\n```\n\nGenerate new mailable class.\n\n```\nphp artisan module:make-mail WelcomeEmail\n```\n\nGenerate new notification class.\n\n```\nphp artisan module:make-notification InvoicePaid\n```\n\nUpdate dependencies for the specified module.\n\n```\nphp artisan module:update ModuleName\n```\n\nUpdate dependencies for all modules.\n\n```\nphp artisan module:update\n```\n\nShow the list of modules.\n\n```\nphp artisan module:list\n```\n\n\u003ca name=\"facades\"\u003e\u003c/a\u003e\n## Facades\n\nGet all modules.\n\n```php\nModule::all();\n```\n\nGet all cached modules.\n\n```php\nModule::getCached()\n```\n\nGet ordered modules. The modules will be ordered by the `priority` key in `module.json` file.\n\n```php\nModule::getOrdered();\n```\n\nGet scanned modules.\n\n```php\nModule::scan();\n```\n\nFind a specific module.\n\n```php\nModule::find('name');\n// OR\nModule::get('name');\n```\n\nFind a module, if there is one, return the `Module` instance, otherwise throw `Nwidart\\Modules\\Exeptions\\ModuleNotFoundException`.\n\n```php\nModule::findOrFail('module-name');\n```\n\nGet scanned paths.\n\n```php\nModule::getScanPaths();\n```\n\nGet all modules as a collection instance.\n\n```php\nModule::toCollection();\n```\n\nGet modules by the status. 1 for active and 0 for inactive.\n\n```php\nModule::getByStatus(1);\n```\n\nCheck the specified module. If it exists, will return `true`, otherwise `false`.\n\n```php\nModule::has('blog');\n```\n\nGet all enabled modules.\n\n```php\nModule::enabled();\n```\n\nGet all disabled modules.\n\n```php\nModule::disabled();\n```\n\nGet count of all modules.\n\n```php\nModule::count();\n```\n\nGet module path.\n\n```php\nModule::getPath();\n```\n\nRegister the modules.\n\n```php\nModule::register();\n```\n\nBoot all available modules.\n\n```php\nModule::boot();\n```\n\nGet all enabled modules as collection instance.\n\n```php\nModule::collections();\n```\n\nGet module path from the specified module.\n\n```php\nModule::getModulePath('name');\n```\n\nGet assets path from the specified module.\n\n```php\nModule::assetPath('name');\n```\n\nGet config value from this package.\n\n```php\nModule::config('composer.vendor');\n```\n\nGet used storage path.\n\n```php\nModule::getUsedStoragePath();\n```\n\nGet used module for cli session.\n\n```php\nModule::getUsedNow();\n// OR\nModule::getUsed();\n```\n\nSet used module for cli session.\n\n```php\nModule::setUsed('name');\n```\n\nGet modules's assets path.\n\n```php\nModule::getAssetsPath();\n```\n\nGet asset url from specific module.\n\n```php\nModule::asset('blog:img/logo.img');\n```\n\nInstall the specified module by given module name.\n\n```php\nModule::install('nwidart/hello');\n```\n\nUpdate dependencies for the specified module.\n\n```php\nModule::update('hello');\n```\n\nAdd a macro to the module repository.\n\n```php\nModule::macro('hello', function() {\n    echo \"I'm a macro\";\n});\n```\n\nCall a macro from the module repository.\n\n```php\nModule::hello();\n```\n\nGet all required modules of a module\n\n```php\nModule::getRequirements('module name');\n```\n\n\u003ca name=\"entity\"\u003e\u003c/a\u003e\n## Module Entity\n\nGet an entity from a specific module.\n\n```php\n$module = Module::find('blog');\n```\n\nGet module name.\n\n```\n$module-\u003egetName();\n```\n\nGet module name in lowercase.\n\n```\n$module-\u003egetLowerName();\n```\n\nGet module name in studlycase.\n\n```\n$module-\u003egetStudlyName();\n```\n\nGet module path.\n\n```\n$module-\u003egetPath();\n```\n\nGet extra path.\n\n```\n$module-\u003egetExtraPath('Assets');\n```\n\nDisable the specified module.\n\n```\n$module-\u003edisable();\n```\n\nEnable the specified module.\n\n```\n$module-\u003eenable();\n```\n\nDelete the specified module.\n\n```\n$module-\u003edelete();\n```\n\nGet an array of module requirements. Note: these should be aliases of the module.\n\n```\n$module-\u003egetRequires();\n```\n\n\u003ca name=\"namespaces\"\u003e\u003c/a\u003e\n## Custom Namespaces\n\nWhen you create a new module it also registers new custom namespace for `Lang`, `View` and `Config`. For example, if you create a new module named blog, it will also register new namespace/hint blog for that module. Then, you can use that namespace for calling `Lang`, `View` or `Config`. Following are some examples of its usage:\n\nCalling Lang:\n\n```php\nLang::get('blog::group.name');\n```\n\nCalling View:\n\n```php\nView::make('blog::index')\n\nView::make('blog::partials.sidebar')\n```\n\nCalling Config:\n\n```php\nConfig::get('blog.name')\n```\n\n## Publishing Modules\n\nHave you created a laravel modules? Yes, I've. Then, I want to publish my modules. Where do I publish it? That's the question. What's the answer ? The answer is [Packagist](http://packagist.org).\n\n\u003ca name=\"auto-scan-vendor-directory\"\u003e\u003c/a\u003e\n### Auto Scan Vendor Directory\n\nBy default the `vendor` directory is not scanned automatically, you need to update the configuration file to allow that. Set `scan.enabled` value to `true`. For example :\n\n```php\n// file config/modules.php\n\nreturn [\n  //...\n  'scan' =\u003e [\n    'enabled' =\u003e true\n  ]\n  //...\n]\n```\n\nYou can verify the module has been installed using `module:list` command:\n\n```\nphp artisan module:list\n```\n\n\u003ca name=\"publishing-modules\"\u003e\u003c/a\u003e\n## Publishing Modules\n\nAfter creating a module and you are sure your module module will be used by other developers. You can push your module to [github](https://github.com) or [bitbucket](https://bitbucket.org) and after that you can submit your module to the packagist website.\n\nYou can follow this step to publish your module.\n\n1. Create A Module.\n2. Push the module to github.\n3. Submit your module to the packagist website.\nSubmit to packagist is very easy, just give your github repository, click submit and you done.\n\n\n## Credits\n\n- [Nicolas Widart](https://github.com/nwidart)\n- [gravitano](https://github.com/gravitano)\n- [All Contributors](../../contributors)\n\n## About Nicolas Widart\n\nNicolas Widart is a freelance web developer specialising on the laravel framework. View all my packages [on my website](https://nicolaswidart.com/projects).\n\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffroiden%2Flaravel-modules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffroiden%2Flaravel-modules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffroiden%2Flaravel-modules/lists"}