Laravel HMVC structure sample project.
sethsandaru/laravel-hmvc-sample is a Laravel package for laravel hmvc structure sample project..
It currently has 29 GitHub stars and 65 downloads on Packagist (latest version v1.0.0).
Install it with composer require sethsandaru/laravel-hmvc-sample.
Discover more Laravel packages by sethsandaru
or browse all Laravel packages to compare alternatives.
Last updated
A sample project, building and using HMVC structure for Laravel 5.7+, 6, 7, 8.
You can find out here: HMVC - WIKI
Key advantages (M.O.R.E):
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.
app/Modulesconfigs/app.phpModule folder name is the alias name to let us load views, language text,...
Example: I have Home module. Alias: home
We need to insert module alias in the beginning like this:
return view('home::home.view', $arrData);
trans('home::home.hello'); // Hello
__('home::home.world'); // World
Just like normal config, you can get your config via your alias like this:
config('home.text'); // get 'text' in home alias
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
Just create migration file (Laravel format) in <ModulePath>/Migrations.
Note:
yyyy_MM_dd_hhmmss_class_name_here.php (follow Laravel format)app/Modules/<insert_module_name/Console/Commandsboot method like this:$this->commands([
MyCommand::class,
]);
Note: Older Laravel versions might not have this opportunity. The current project is using Laravel 5.7
If you got any problems or any questions, feel free to ask me.
Copyright © 2018-2021 by Seth Phat.