{"id":13399767,"url":"https://github.com/pingpong-labs/modules","last_synced_at":"2025-05-15T13:08:40.279Z","repository":{"id":13940316,"uuid":"16640096","full_name":"pingpong-labs/modules","owner":"pingpong-labs","description":"Laravel 5 Modules","archived":false,"fork":false,"pushed_at":"2020-09-30T18:49:20.000Z","size":713,"stargazers_count":576,"open_issues_count":70,"forks_count":149,"subscribers_count":47,"default_branch":"master","last_synced_at":"2025-04-10T06:39:18.483Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pingpong-labs.github.io/docs/modules.html","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pingpong-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-08T09:28:34.000Z","updated_at":"2025-02-13T18:59:16.000Z","dependencies_parsed_at":"2022-08-07T07:15:58.928Z","dependency_job_id":null,"html_url":"https://github.com/pingpong-labs/modules","commit_stats":null,"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingpong-labs%2Fmodules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingpong-labs%2Fmodules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingpong-labs%2Fmodules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingpong-labs%2Fmodules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pingpong-labs","download_url":"https://codeload.github.com/pingpong-labs/modules/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254346624,"owners_count":22055808,"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":[],"created_at":"2024-07-30T19:00:42.477Z","updated_at":"2025-05-15T13:08:35.260Z","avatar_url":"https://github.com/pingpong-labs.png","language":"PHP","readme":"Laravel 5 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\n`pingpong/modules` is a laravel package which created to manage your large laravel app using modules. Module is like a laravel package, it have some views, controllers or models. This package is supported and tested in both Laravel 4 and Laravel 5.\n\n\u003ca name=\"upgrade-guide\"\u003e\u003c/a\u003e\n## Upgrade Guide\n\n#### To 2.0.18\n\nIf you have been updated to version `2.0.18`, please read [this release note](https://github.com/pingpong-labs/modules/releases/tag/2.0.18).\n\n#### To 2.0.10\n\nPreviously, we add two service provider from this package. In version `2.0.5`, we just need register one service provider. Now, we can remove `Pingpong\\Modules\\Providers\\BootstrapServiceProvider` from `providers` array, because now it service provider is registered automatically by `Pingpong\\Modules\\ModulesServiceProvider`.\n\n#### From Laravel 4 to Laravel 5\n\nIf upgrade your Laravel app from Laravel 4 to Laravel 5, there is a few things to do if you are using this package. You will receive some kind errors about config not loaded. To fix this issue, please follow this instruction.\n\n- If you publish the package's configuration file, you need to move the config file from `app/config/packages/pingpong/modules/config.php` to `app/config/modules.php`.\n- If you are not publish the package's configuration file and you want to publish the config file, just run `php artisan vendor:publish` command and you are done. \n\n#### From 1.1.* to 1.2.0\n\nNew configuration file. This breaking change affected if you publish the configuration file from this package. To fix this issue, create new config file called `config.php` in your `app/config/packages/pingpong/modules/` directory. Next move the array contents from `paths.php` file to `paths` array in new configuration file.\nYour config file will looks like [this](https://github.com/pingpong-labs/modules/blob/1.2.0/src/config/config.php).\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n## Installation\n\nTo install through composer, simply put the following in your composer.json file:\n\n```json\n{\n    \"require\": {\n        \"pingpong/modules\": \"~2.1\"\n    }\n}\n```\n\nAnd then run `composer install` to fetch the package.\n\n#### Quick Installation\n\nYou could also simplify the above code by using the following command:\n\n```\ncomposer require \"pingpong/modules:~2.1\"\n```\n\n#### Add Service Provider\n\nNext add the following service provider in `config/app.php`.\n\n```php\n'providers' =\u003e array(\n  'Pingpong\\Modules\\ModulesServiceProvider',\n),\n```\n\nNext, add the following aliases to `aliases` array in the same file.\n\n```\n'aliases' =\u003e array(\n  'Module' =\u003e 'Pingpong\\Modules\\Facades\\Module',\n),\n\n```\n\nNext publish the package's configuration file by run :\n\n```\nphp artisan vendor:publish\n```\n\n#### Autoloading\n\nBy default controllers, entities or repositories not loaded automatically. You can autoload all that stuff 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. Please see [#26](https://github.com/pingpong-labs/modules/pull/26).\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```\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```\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.\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```\nphp artisan module:publish-migration blog\n```\n\nFor all modules.\n```\nphp artisan module:publish-migration\n```\n\nEnable the specified module.\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```\nphp artisan module:make-middleware Auth\n```\n\nUpdate dependencies for the specified module.\n```\nphp artisan module:update ModuleName\n```\n\nUpdate dependencies for all modules.\n```\nphp artisan module:update\n```\n\nShow the list of modules.\n```\nphp artisan module:list\n```\n\n\u003ca name=\"facades\"\u003e\u003c/a\u003e\n## Facades\n\nGet all modules.\n```php\nModule::all();\n```\n\nGet all cached modules.\n```php\nModule::getCached()\n```\n\nGet ordered modules. The modules will be ordered by the `priority` key in `module.json` file.\n```php\nModule::getOrdered();\n```\n\nGet scanned modules.\n```php\nModule::scan();\n```\n\nFind a specific module.\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 `Pingpong\\Modules\\Exeptions\\ModuleNotFoundException`.\n```php\nModule::findOrFail('module-name');\n```\n\nGet scanned paths.\n```php\nModule::getScanPaths();\n```\n\nGet all modules as a collection instance.\n```php\nModule::toCollection();\n```\n\nGet modules by the status. 1 for active and 0 for inactive.\n```php\nModule::getByStatus(1);\n```\n\nCheck the specified module. If it exists, will return `true`, otherwise `false`.\n```php\nModule::has('blog');\n```\n\nGet all enabled modules.\n```php\nModule::enabled();\n```\n\nGet all disabled modules.\n```php\nModule::disabled();\n```\n\nGet count of all modules.\n```php\nModule::count();\n```\n\nGet module path.\n```php\nModule::getPath();\n```\n\nRegister the modules.\n```php\nModule::register();\n```\n\nBoot all available modules.\n```php\nModule::boot();\n```\n\nGet all enabled modules as collection instance.\n```php\nModule::collections();\n```\n\nGet module path from the specified module.\n```php\nModule::getModulePath('name');\n```\n\nGet assets path from the specified module.\n```php\nModule::getAssetPath('name');\n```\n\nGet config value from this package.\n```php\nModule::config('composer.vendor');\n```\n\nGet used storage path.\n```php\nModule::getUsedStoragePath();\n```\n\nGet used module for cli session.\n```php\nModule::getUsedNow();\n// OR\nModule::getUsed();\n```\n\nSet used module for cli session.\n```php\nModule::setUsed('name');\n```\n\nGet modules's assets path.\n```php\nModule::getAssetsPath();\n```\n\nGet asset url from specific module.\n```php\nModule::asset('blog:img/logo.img');\n```\n\nInstall the specified module by given module name.\n```php\nModule::install('pingpong-modules/hello');\n```\n\nUpdate dependencies for the specified module.\n```php\nModule::update('hello');\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$module-\u003egetName();\n```\n\nGet module name in lowercase.\n```\n$module-\u003egetLowerName();\n```\n\nGet module name in studlycase.\n```\n$module-\u003egetStudlyName();\n```\n\nGet module path.\n```\n$module-\u003egetPath();\n```\n\nGet extra path.\n```\n$module-\u003egetExtraPath('Assets');\n```\n\nDisable the specified module.\n```\n$module-\u003eenable();\n```\n\nEnable the specified module.\n```\n$module-\u003edisable();\n```\n\nDelete the specified module.\n```\n$module-\u003edelete();\n```\n\n\u003ca name=\"namespaces\"\u003e\u003c/a\u003e\n## Custom Namespaces\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```php\nLang::get('blog::group.name');\n```\n\nCalling View:\n```php\nView::make('blog::index')\n\nView::make('blog::partials.sidebar')\n```\n\nCalling Config:\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). In pingpong/modules version \u003e= 1.2.0, when you generate a module, you will see there is a new file generated called `composer.json`.\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","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingpong-labs%2Fmodules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpingpong-labs%2Fmodules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingpong-labs%2Fmodules/lists"}