arwp / mvc
For building Model-View-Controller (MVC) pattern in laravel
Installs: 347
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 2
Open Issues: 0
pkg:composer/arwp/mvc
Requires
- php: >=8.1
- spatie/laravel-html: ^3.2
README
MVC Generator is a powerful package designed to streamline the creation of new modules with full CRUD functionality and generate corresponding views. This tool is an invaluable asset for accelerating your Laravel projects.
Crafted specifically for arwp/main-master, its code structure is optimized for seamless integration.
Made with ❤️ by [ARWP](https://github.com/arwahyu01)
Requirements
- Use This Package: arwp/main-master
- Laravel: 11.0 or higher
- PHP: 8.2 or higher
Features
-
Module Generation:
Use the commandphp artisan make:mvc [model name]to generate a new module that includes:- ✅ Controller: Integrated with complete CRUD functionality.
- ✅ Model: Configured with fillable fields and defined relationships.
- ✅ Migration: Automatically creates the required database tables and relationships.
- ✅ Views: Pre-built views supporting CRUD operations.
- ✅ Route: A dedicated route for module operations.
-
Module Deletion:
- Run
php artisan delete:mvc [name]to delete MVC files one by one (with confirmation prompts). - Run
php artisan delete:mvc [name] --allto remove all related files and database tables.
- Run
Installation
Install the package via Composer:
composer require arwp/mvc
Creating a New Module
To create a new module, execute:
php artisan make:mvc [model name]
Examples:
-
Standard Module Creation:
php artisan make:mvc User
-
Customized Component Generation:
Generate only specific components (e.g., model and view) by using flags:
php artisan make:mvc User mv # 'm' for model, 'v' for view, 'c' for controller, 't' for migration, 'r' for route -
Single Component Creation:
For example, to generate only views:
php artisan make:mvc User view
Deleting a Module
To remove a module along with its associated files and database tables, run:
php artisan delete:mvc [model name]
Setup and Configuration
-
Register the Service Provider:
Add the service provider in yourconfig/app.php:'providers' => [ // ... Arwp\Mvc\MvcServiceProvider::class, // ... ],
-
Publish the Package Resources:
Publish the necessary resource files by running:php artisan vendor:publish --provider="Arwp\Mvc\MvcServiceProvider"This command will publish:
config/mvc.phproutes/mvc-route.phpConsole/Commands/createMvc.phpConsole/Commands/deleteMvc.php
-
Configure Routing:
Update yourRouteServiceProvider.phpto include the MVC routes. For example:public function boot() { // ... Route::middleware(['web', 'auth', 'backend']) ->namespace('App\Http\Controllers\Backend') ->group(base_path('routes/mvc-route.php')); // ... }
-
Customize Paths:
In the publishedconfig/mvc.phpfile, adjust the paths to suit your project structure:return [ 'path_controller' => 'app/Http/Controllers/Backend', // Controller folder path 'path_model' => 'app/Models', // Model folder path 'path_view' => 'views/backend', // View folder path (e.g., views/backend or views/frontend) 'path_route' => 'routes/mvc-route.php', // Route file path (default: routes/mvc-route.php) 'route_prefix' => '', // Optional route prefix (e.g., backend, admin) ];
To modify the default route file, simply update the
path_routesetting accordingly:return [ // ... 'path_route' => 'routes/web.php', // Change this to your desired route file path // ... ];
Lastly, ensure your designated route file (e.g.,
routes/web.php) contains the following marker://{{route replacer}} DON'T REMOVE THIS LINE
License
MVC Generator is released under the MIT License.
MVC Generator is designed to enhance the efficiency and simplicity of your development workflow. If you find this project valuable, your support with a star ⭐️ is greatly appreciated. Thank you for your contribution and happy coding! 🚀