sethsandaru/laravel-hmvc-sample
Composer 安装命令:
composer create-project sethsandaru/laravel-hmvc-sample
包简介
Laravel HMVC structure sample project.
关键字:
README 文档
README
A sample project, building and using HMVC structure for Laravel 5.7+, 6, 7, 8.
What is HMVC?
You can find out here: HMVC - WIKI
Key advantages (M.O.R.E):
- Modularization: Reduction of dependencies between the disparate parts of the application.
- Organization: Having a folder for each of the relevant triads makes for a lighter work load.
- Usability: By nature of the design it is easy to reuse nearly every piece of code.
- Extensibility: Makes the application more extensible without sacrificing ease of maintenance.
Other advantages
- Able to achieve Microservice with ease. Splitting up the Modules into Services would be blazing fast.
- In the Project itself it's like a Mono-Repo strategy.
Laravel HMVC Structure - this project
- Top - Base MVC - Laravel App
- Module 1 MVC - Small Laravel App
- Module 2 MVC - Small Laravel App
- ...
- Module n MVC - Small Laravel App
Module Structure
- ModuleName
- Configs: Your config files here.
- Http:
- Controllers: Your controllers here.
- Requests
- Languages: your language files here (translation)
- en
- vi
- ...
- Libraries: your special library classes file here.
- Models: your models here.
- Views: your view file here.
- Routes: all the routes of the module
- routes.php: routes of this module.
- Services: your service handlers here
- Providers: Service Provider
- Policies: policies of the module
So you can see, a Module is just a small Laravel Application. You don't have to create a full structure to make it work.
The most important part is: ServiceProvider. Without that we can't boot up the Module.
How to create a new module?
- Create your module folder inside
app/Modules - Inside your module folder, create folder that you need like the structure above (ServiceProvider, Views,...)
- Create a ServiceProvider and register it in
configs/app.php - Test your module
How to access View/Language/Config?
Module folder name is the alias name to let us load views, language text,...
Example: I have Home module. Alias: home
Load view
We need to insert module alias in the beginning like this:
return view('home::home.view', $arrData);
Get language (translation) text
trans('home::home.hello'); // Hello __('home::home.world'); // World
Get Config Value
Just like normal config, you can get your config via your alias like this:
config('home.text'); // get 'text' in home alias
Migrations
How it works?
When you run php artisan migrate, it will run like this:
- Base/Core (database/migrations) first - Thought each module - Module 1 - Module 2 - ... - Module n
Create migration
Just create migration file (Laravel format) in <ModulePath>/Migrations.
Note:
- Filename must be:
yyyy_MM_dd_hhmmss_class_name_here.php(follow Laravel format)
Console Command registration
- Create your command in
app/Modules/<insert_module_name/Console/Commands - Open your module's ServiceProvider, register it in
bootmethod like this:
$this->commands([ MyCommand::class, ]);
Note: Older Laravel versions might not have this opportunity. The current project is using Laravel 5.7
Final
If you got any problems or any questions, feel free to ask me.
Copyright © 2018-2021 by Seth Phat.
sethsandaru/laravel-hmvc-sample 适用场景与选型建议
sethsandaru/laravel-hmvc-sample 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 65 次下载、GitHub Stars 达 29, 最近一次更新时间为 2018 年 10 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sethsandaru/laravel-hmvc-sample 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sethsandaru/laravel-hmvc-sample 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sethsandaru/laravel-hmvc-sample 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Alfabank REST API integration
High-performance, opinionated PHP 8 web framework with O(1) routing, parallel async MySQL, type-safe asset bridge, and React-island frontend
Laravel package for Accurate Online API integration.
The skeleton application for the Geoffrey agent framework.
Shared RCX Laravel DataTables UI and configuration helpers.
统计信息
- 总下载量: 65
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 29
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-10-17