jamacio/module-laravel
最新稳定版本:v1.0.3
Composer 安装命令:
composer require jamacio/module-laravel
包简介
Laravel module with auto-discovery support. Organize all Laravel main folders in a single module for easier maintenance and discovery.
README 文档
README
Use the command below to install the package via Composer. After installation, follow the steps to create modules in the app/Code/YourModuleName folder:
composer require jamacio/module-laravel
Module Laravel
Module Laravel is a package designed to streamline Laravel's core folder structure by consolidating Routes, Views and Migrations into a single module folder. This approach simplifies maintenance and improves discoverability for modular applications.
Overview
In traditional Laravel applications, core folders are distributed across multiple directories (e.g., routes/, resources/views/, database/migrations/, etc.). This package centralizes these components into a unified module structure under a dedicated folder (e.g., app/Code/YourModuleName). Key advantages include:
- Simplified Maintenance: Centralize module-specific assets for easier management.
- Improved Discoverability: Quickly locate and manage module-specific resources.
- Auto-Discovery Support: Automatically registers service providers using Laravel’s package auto-discovery feature.
Features
- Organized Folder Structure: Groups Routes, Views and Migrations into a single module folder.
- Auto-Discovery: Utilizes Laravel’s auto-discovery to register service providers without manual configuration.
- Dependency Management: Supports module dependency ordering through an XML configuration file (
module.xml). - Modular Routing and Views: Allows module-specific routes and views to override or extend default Laravel functionality.
- Dynamic Resource Loading: Automatically loads migrations for each module.
Folder Structure
After Laravel installation, your module folder structure will look like this:
app/
└── Code/
└── YourModuleName/
├── module.xml
├── Routes/
│ ├── web.php
│ └── api.php
├── Views/
│ └── index.blade.php
├── Database/
│ └── Migrations/
│ └── 2021_01_01_000000_create_example_table.php
├── Controllers/
│ └── YourModuleController.php
This structure organizes all module-specific assets under a single folder, simplifying management and maintenance. Each subfolder serves a specific purpose:
- module.xml: Contains metadata and dependencies for the module.
- Routes: Includes route files (
web.phpandapi.php) for module-specific routes. - Views: Stores Blade templates for the module.
- Database: Contains subfolders for migrations.
- Controllers: Houses controllers for managing HTTP requests.
Module Configuration
The module must reside within the folder: app/Code/YourModuleName, and it must include a module.xml file with the same name as the folder. Below is an example:
<?xml version="1.0" ?> <config> <module name="SampleModule"/> </config>
Module Dependency Sequence
If you need a module to execute after another, you can define the sequence in the module.xml file as shown below:
<?xml version="1.0" ?> <config> <module name="SampleModule"/> <sequence> <module name="SampleModuleOld"/> </sequence> </config>
This ensures that SampleModule will execute after SampleModuleOld.
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-25