{"id":15561087,"url":"https://github.com/learn2torials/laravel-modular","last_synced_at":"2025-04-23T21:48:34.136Z","repository":{"id":57013389,"uuid":"164318620","full_name":"learn2torials/laravel-modular","owner":"learn2torials","description":"Write Modular Apps using laravel framework.","archived":false,"fork":false,"pushed_at":"2021-07-17T17:56:45.000Z","size":29,"stargazers_count":14,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T21:48:30.934Z","etag":null,"topics":["app","architecture","laravel","laravel5","modular","modular-apps","translation"],"latest_commit_sha":null,"homepage":"https://learn2torials.com","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/learn2torials.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":"2019-01-06T15:11:33.000Z","updated_at":"2024-01-06T15:27:24.000Z","dependencies_parsed_at":"2022-08-21T13:40:56.210Z","dependency_job_id":null,"html_url":"https://github.com/learn2torials/laravel-modular","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learn2torials%2Flaravel-modular","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learn2torials%2Flaravel-modular/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learn2torials%2Flaravel-modular/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learn2torials%2Flaravel-modular/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/learn2torials","download_url":"https://codeload.github.com/learn2torials/laravel-modular/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522295,"owners_count":21444510,"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":["app","architecture","laravel","laravel5","modular","modular-apps","translation"],"created_at":"2024-10-02T16:05:23.390Z","updated_at":"2025-04-23T21:48:34.113Z","avatar_url":"https://github.com/learn2torials.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Modular App Plugin\n\n[![Laravel](https://img.shields.io/badge/laravel-5-orange.svg)](http://laravel.com)\n[![Release](https://poser.pugx.org/learn2torials/laravel-modular/v/stable)](https://github.com/learn2torials/laravel-modular/releases)\n![Issues](https://img.shields.io/github/issues/learn2torials/laravel-modular.svg)\n![Licence](https://img.shields.io/github/license/learn2torials/laravel-modular.svg)\n\nTurn your existing laravel app into modular application. Laravel modular plugin allows you to write modular plugins for laravel.\n\nLet's say, you are building a blog application. Your blog needs to have following features:\n\n- comments\n- blog post\n- user management etc..\n\nYou can turn this features into a module and bundle your logic so that you can easily use this module for your other projects. You can easily turn on/off your module.\n\n# Plugin Requirements\n\n- PHP \u003e= 7.2\n- Laravel \u003e= 6.0\n\n# Newer Laravel Plugin\nFor older version \u003e= 8.0 of Laravel use this plugin [Modular Laravel](https://packagist.org/packages/learn2torials/modular-laravel)\n\n\n# How to install this plugin\n\nRun following command to your existing project.\n\n```\n\n# install this plugin\ncomposer require \"learn2torials/laravel-modular\"\n\n# create module using artisan\nphp artisan make:module comments\n```\n\nAbove command will create a new directory under App/Modules with following structure.\n\n```\nApp\n|- Modules\n   |-- Comments\n      |-- Controllers\n      |-- Models\n      |-- Views\n      |-- Migrations\n         |-- Seeder\n      |-- Translations\n         |-- en\n             |-- general.php\n         |-- fr\n             |-- general.php\n      |-- config.php\n      |-- routes.php\n```\n\nNext, once this folder structure is generated you can turn on this module by creating console.php file in _config_ directory.\n\n```\n\u003c?php\n\n/*\n|--------------------------------------------------------------------------\n| Configuration File\n|--------------------------------------------------------------------------\n|\n| You can overwrite default configuration here according to your app requirements.\n|\n*/\nreturn [\n    \"prefix\"   =\u003e null,\n    \"i18n\"     =\u003e false,\n    \"https\"    =\u003e false,\n    \"modules\"  =\u003e [\n        \"comments\" =\u003e true\n    ]\n];\n```\n\nThat is it, your module is now enabled. You can verify that your module is working by browsing\n\n```\nhttp://yourdomain.com/comments\n```\n\n### Add prefix before all your modules. Set following config in _config/console.php_ file.\n\n```\n\"prefix\" =\u003e \"admin\",\n```\n\nNow, your module url will be:\n\n```\nhttp://yourdomain.com/admin/comments\n```\n\n### Enable translation for you module. Set following config in _config/console.php_ file.\n\n```\n\"i18n\" =\u003e true,\n```\n\nNow, your module url will be:\n\n```\nhttp://yourdomain.com/en/ca/comments      -\u003e for english translation\nhttp://yourdomain.com/fr/ca/comments      -\u003e for french translation\n```\n\n### When prefix is enabled\n\n```\nhttp://yourdomain.com/en/ca/admin/comments -\u003e if prefix is admin\nhttp://yourdomain.com/fr/ca/admin/comments -\u003e if prefix is admin\n```\n\nHow to use translations. Check your view file in your module to get the idea of usage:\n\n```\n{{ __('module::file_name.translation_key') }}\n```\n\n### Module Configurations\n\nOnce module is enabled you can access module related configurations using following syntax.\n\nFor example: if you have installed a user module. Configuration file for user module is located in _Modules/User/config.php_\n\n```\n\u003c?php\n\n/*\n|--------------------------------------------------------------------------\n| User Module Configurations\n|--------------------------------------------------------------------------\n|\n| Here you can add configurations that relates to your [User] module\n| Only make sure not to add any other configs that do not relate to this\n| User Module ...\n|\n*/\nreturn [\n\n    // module name\n    'name' =\u003e 'User',\n\n    // register middleware\n    'middleware' =\u003e [\n        'user' =\u003e \\App\\Modules\\User\\Middleware\\UserAuthenticated::class,\n    ],\n\n    // register service providers\n    'providers' =\u003e [\n        \\App\\Modules\\User\\Provider\\UserProvider::class\n    ],\n\n    // register route middleware\n    'route_middleware' =\u003e ['user'],\n\n    // database seeder\n    'seeder' =\u003e [\n        __DIR__. '/Migrations/Seeder/UsersTableSeeder.php'\n    ]\n];\n```\n\n### How to run module migration/seeder\n\nTo run migration or seeder for your modules. Add seeder to config file and run following commands.\n\n```\n\n# run module migrations\nphp artisan migrate\n\n# run module seeders\nphp artisan db:seed --class=\"L2T\\Database\\Seeder\"\n```\n\n# Reference\n\nExample is shown on [https://learn2torials.com/a/laravel-module-management](https://learn2torials.com/a/laravel-module-management)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flearn2torials%2Flaravel-modular","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flearn2torials%2Flaravel-modular","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flearn2torials%2Flaravel-modular/lists"}