{"id":21499850,"url":"https://github.com/hexters/laramodule","last_synced_at":"2025-07-15T21:31:54.019Z","repository":{"id":54999864,"uuid":"458252273","full_name":"hexters/laramodule","owner":"hexters","description":"Laramodule is an HMVC pattern for the Laravel framework.","archived":false,"fork":false,"pushed_at":"2023-10-18T11:43:51.000Z","size":211,"stargazers_count":32,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-08T09:33:50.437Z","etag":null,"topics":["hmvc-framework","laravel","modular-design","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hexters.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-02-11T16:02:51.000Z","updated_at":"2024-07-02T02:33:05.000Z","dependencies_parsed_at":"2023-10-15T08:04:38.022Z","dependency_job_id":"94479ea2-1c5c-4bd0-ac79-ca0dcb73dd4a","html_url":"https://github.com/hexters/laramodule","commit_stats":{"total_commits":75,"total_committers":1,"mean_commits":75.0,"dds":0.0,"last_synced_commit":"2fe6f3a24d5709cefb8b6bc391b350a757858e53"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexters%2Flaramodule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexters%2Flaramodule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexters%2Flaramodule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexters%2Flaramodule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hexters","download_url":"https://codeload.github.com/hexters/laramodule/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226071362,"owners_count":17569169,"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":["hmvc-framework","laravel","modular-design","php"],"created_at":"2024-11-23T17:18:43.574Z","updated_at":"2024-11-23T17:18:44.199Z","avatar_url":"https://github.com/hexters.png","language":"PHP","funding_links":["https://paypal.me/asepss19"],"categories":[],"sub_categories":[],"readme":"# Laravel HMVC V4\n\n[![Latest Stable Version](https://poser.pugx.org/hexters/laramodule/v/stable)](https://packagist.org/packages/hexters/laramodule)\n[![Total Downloads](https://poser.pugx.org/hexters/laramodule/downloads)](https://packagist.org/packages/hexters/laramodule)\n[![License](https://poser.pugx.org/hexters/laramodule/license)](https://packagist.org/packages/hexters/laramodule)\n\nLaramodule is a package for the Laravel framework that allows developers to organize and manage modules within their web application. It is designed to make it easy to create, manage and reuse modular components within a Laravel application.\n\nWith Laramodule, developers can create new modules that can be easily added to their application, and can also manage existing modules. It also allows developers to keep their code organized and maintainable, by separating different functionality into different modules. Each module can include its own controllers, views, routes, and other components.\n\nLaramodule also provides an easy to use API for interacting with modules and their components. This allows developers to perform tasks such as enabling or disabling modules, and accessing module specific data or functionality.\n\nLaramodule is a powerful tool for developers who want to create modular and maintainable applications with Laravel. It can help developers to speed up development, improve code quality and maintain a cleaner structure of their application.\n\n\n\n## Doc. Versions\n|Version|Doc.|\n|-|-|\n|V3|[Read Me](https://github.com/hexters/laramodule/blob/main/src/releasedoc/v3.md)|\n\nTo install through Composer, by run the following command:\n\n```bash\ncomposer require hexters/laramodule\n```\n\n## Autoloading\nBy default the module classes are not loaded automatically. You can autoload your modules using `psr-4`. For example :\n```json\n{\n  \"autoload\": {\n    \"psr-4\": {\n      \"App\\\\\": \"app/\",\n      \"Modules\\\\\": \"Modules/\",\n      \"Database\\\\Factories\\\\\": \"database/factories/\",\n      \"Database\\\\Seeders\\\\\": \"database/seeders/\"\n    }\n  }\n}\n```\nAnd make `Modules` directory in your root project folder\n\n```bash\nmkdir Modules\n```\n\nDon't forget to run the commands below\n\n```bash\ncomposer dump-autoload\n```\n\n## Managing assets\n\nInstall node module pacakge\n```bash\nnpm install -D @hexters/ladmin-vite-input\n```\n\nOpen `vite.config.js` in your project and follow the instruction below.\n\n```js\n\n. . . \nimport ladminViteInputs from '@hexters/ladmin-vite-input'\n. . .\n\nexport default defineConfig({\n    plugins: [\n        laravel({\n            input: ladminViteInputs([\n                'resources/css/app.css',\n                'resources/js/app.js'\n            ]),\n            refresh: true,\n        }),\n    ],\n});\n\n\n```\n\nInstall the node module package in all module folders\n```bash\nphp artisan module:npm --install\nphp artisan module:npm --update\n```\n\nAnd run the vite command below\n\n```bash\nnpm run dev\n\nnpm run build\n```\n\n## Artisan\n```bash\nphp artisan module:make Blog --command=OPTIONAL\nphp artisan module:make-cast BlogCast --module=Blog\nphp artisan module:make-channel BlogChannel --module=Blog\nphp artisan module:make-command BlogCommand --module=Blog\nphp artisan module:make-component BlogComponent --module=Blog\nphp artisan module:make-controller BlogController --module=Blog\nphp artisan module:make-event BlogEvent --module=Blog\nphp artisan module:make-exception BlogException --module=Blog\nphp artisan module:make-factory BlogFactory --module=Blog\nphp artisan module:make-job BlogJob --module=Blog\nphp artisan module:make-listener BlogListener --module=Blog\nphp artisan module:make-mail BlogMail --module=Blog\nphp artisan module:make-middleware BlogMiddleware --module=Blog\nphp artisan module:make-migration BlogMigration --module=Blog\nphp artisan module:make-model BlogModel --module=Blog\nphp artisan module:make-notification BlogNotification --module=Blog\nphp artisan module:make-observer BlogObserver --module=Blog\nphp artisan module:make-policy BlogPolicy --module=Blog\nphp artisan module:make-provider BlogProvider --module=Blog\nphp artisan module:make-request BlogRequest --module=Blog\nphp artisan module:make-resource BlogResource --module=Blog\nphp artisan module:make-rule BlogRule --module=Blog\nphp artisan module:make-scope BlogScope --module=Blog\nphp artisan module:make-seeder BlogSeeder --module=Blog\nphp artisan module:make-test BlogTest --module=Blog\nphp artisan module:publish Blog\n```\n\nHappy coding ☕\n\n# Livewire Support\n\nWe have a livewire version but it is still in the experimental stage, please see the full documentation below.\n\n### [Livewire HMVC Documentation](https://github.com/hexters/wirehmvc)\n\n# Inertia Support\n\nLaramodule is already supported for integration with InertiaJs. Follow the official Inertia.js website to see the installation steps. [inertiajs.com](https://inertiajs.com)\n\n## Inertia with VueJs\n\nFollow the command below to create a module and select `Inertia With VueJs` in preset options.\n```bash\nphp artisan module:make Blog\n```\n\nYou can run the command initialize inertia with vue for an existing module as below, but remember that. The `route.php` file will be replaced by a new file.\n\n```bash\nphp artisan module:inertia-vue --module=Blog\n```\n\nCreate a new javascript file in your root project directory with name `inertia.js` and paste code below.\n```js\nimport { createApp, h } from 'vue'\nimport { createInertiaApp } from '@inertiajs/vue3'\n\nconst getPage = (name) =\u003e {\n\n    let names = (name).split('::');\n    let module = names.shift();\n    let page = names.pop();\n\n    const pages = import.meta.glob('./Modules/**/*.vue', { eager: true })\n    return pages[`./Modules/${module}/Resources/pages/${page}.vue`]\n}\n\ncreateInertiaApp({\n    resolve: getPage,\n    setup({ el, App, props, plugin }) {\n        createApp({ render: () =\u003e h(App, props) })\n            .use(plugin)\n            .mount(el)\n    },\n})\n\n```\n\nAdd `inertia.js` to `vite.config.js`\n\n```js\n. . . \n\nexport default defineConfig({\n    plugins: [\n        vue(),\n        laravel({\n            input: ladminViteInputs([\n                'resources/css/app.css',\n                'resources/js/app.js',\n\n                'inertia.js', // \u003c--- add here\n\n            ]),\n            refresh: true,\n        }),\n    ],\n});\n```\n\nOpen your `app.blade.php` and change vite load assets. \n```html\n\n. . . \n\n \u003chead\u003e\n\n    . . . \n\n    @vite(['inertia.js', 'resources/css/app.css'])\n\n    . . .\n\n \u003c/head\u003e\n \n. . . \n\n```\n\n## Inertia with React\n\nFollow the command below to create a module and select `Inertia With ReactJs` in preset options.\n```bash\nphp artisan module:make Blog\n```\nYou can run the command initialize inertia with react for an existing module as below, but remember that. The `route.php` file will be replaced by a new file.\n\n```bash\nphp artisan module:inertia-react --module=Blog\n```\nCreate a new javascript file in your root project directory with name `inertia.jsx` and paste code below.\n```js\nimport React from 'react'\nimport { createInertiaApp } from '@inertiajs/react'\nimport { createRoot } from 'react-dom/client'\nimport { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'\n\n\nconst getPage = (name) =\u003e {\n\n    let names = (name).split('::');\n    let module = names.shift();\n    let page = names.pop();\n\n    return resolvePageComponent(\n        `./Modules/${module}/Resources/pages/${page}.jsx`,\n        import.meta.glob('./Modules/**/*.jsx', { eager: true })\n    );\n}\n\ncreateInertiaApp({\n    resolve: getPage,\n    setup({ el, App, props }) {\n        createRoot(el).render(\u003cApp {...props} /\u003e)\n    },\n})\n\n```\nAdd `inertia.jsx` to `vite.config.js`\n\n```js\n. . . \nimport react from '@vitejs/plugin-react';\n\nexport default defineConfig({\n    plugins: [\n        react(),\n        laravel({\n            input: ladminViteInputs([\n                'resources/css/app.css',\n                'resources/js/app.js',\n\n                'inertia.jsx', // \u003c--- add here\n\n            ]),\n            refresh: true,\n        }),\n    ],\n});\n```\n\nOpen your `app.blade.php` and change vite load assets. \n```html\n\n. . . \n\n \u003chead\u003e\n\n    . . . \n\n    @viteReactRefresh\n    @vite(['inertia.jsx', 'resources/css/app.css'])\n\n    . . . \n\n \u003c/head\u003e\n \n. . . \n\n```\n\n\n## Tailwind Setup\n\nFor Tailwindcss, you need a few changes in `tailwind.config.js`\n\n```js\n/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n  content: [\n\n    . . .\n\n    \"./Modules/**/Resources/**/*.{blade.php,js,vue}\",\n    \"./resources/**/*.{blade.php,js}\",\n\n    . . .\n\n  ],\n  \n  . . . \n\n```\n\n## Helpers\n\nModule path\n\n```php\nmodule_path('Blog');\n\nmodule_path('Blog', 'target/path');\n```\n\nlist of all module paths\n\n```php\nmodule_path_lists();\n```\nlist of all module paths\n\n```php\nmodule_name_lists();\n```\n\nEnable Module\n```php\nmodule_enable('Blog')\n```\n\nDisable Module\n```php\nmodule_disable('Blog')\n```\n\nGet module status\n\n```php\nmodule_status('Blog')\n```\n\nGrouping module by status\n\n```php\nmodule_group_status()\n```\nView module details\n\n```php\nmodule_details('Blog')\n```\n\nGet active module\n\n```php\nmodule_active('Blog')\n```\n# Events\n\nLaramodule has two events when enabling and disabling the module that can be listened to for specific purposes.\n\nYou can read how to use events \u0026 listeners in the [official documentation.](https://laravel.com/docs/master/events#registering-events-and-listeners)\n\n```php\n\nuse Hexters\\Laramodule\\Events\\ModuleDisabled;\nuse Hexters\\Laramodule\\Events\\ModuleEnabled;\n\n/**\n * The event listener mappings for the application.\n *\n * @var array\n */\nprotected $listen = [\n    ModuleDisabled::class =\u003e [\n        // ...\n    ],\n \n    ModuleEnabled::class =\u003e [\n        // ...\n    ],\n];\n```\n\n\n\n# Supporting the project\nYou can support the maintainer of this project through the referral links below\n- [**Sign up for DigitalOcean**](https://www.digitalocean.com/?refcode=36844cd4f4b4\u0026utm_campaign=Referral_Invite\u0026utm_medium=Referral_Program\u0026utm_source=badge)\n- [**PayPal**](https://paypal.me/asepss19)\n\nFollow package updates on my X [@hexters](https://twitter.com/hexters)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexters%2Flaramodule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexters%2Flaramodule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexters%2Flaramodule/lists"}