dev-sajid/laravel-modular 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dev-sajid/laravel-modular

最新稳定版本:2.0.0

Composer 安装命令:

composer require dev-sajid/laravel-modular

包简介

Lightweight Laravel modularization: drop-in modules under modules/ with auto-discovery, no external dependencies.

README 文档

README

Latest Version on Packagist Total Downloads MIT Licensed

Lightweight module system for Laravel 11+ applications. Drop modules under modules/{Name} and they are auto-discovered with zero configuration.

Features

  • 🚀 Zero Dependencies: No external packages required
  • 🔍 Auto-Discovery: Modules are automatically discovered and registered
  • 📦 Convention-based: Follow simple naming conventions for instant setup
  • 🎯 Laravel 11+ Compatible: Built for modern Laravel applications
  • 🛠️ Artisan Integration: Generate modules with php artisan make:module
  • 📁 Flexible Structure: Support for routes, views, migrations, config, translations, and more
  • High Performance: Lightweight with minimal overhead

Requirements

  • PHP 8.2 or higher
  • Laravel 11.0 or higher

Installation

Install the package via Composer:

composer require dev-sajid/laravel-modular

The package will auto-register thanks to Laravel's package auto-discovery.

Quick Start

  1. Generate a module:

    php artisan make:module Blog
  2. Your module structure:

    modules/
    └── Blog/
        ├── BlogServiceProvider.php
        ├── Http/
        │   └── Controllers/
        │       └── BlogController.php
        ├── routes/
        │   └── web.php
        ├── resources/
        │   └── views/
        │       └── index.blade.php
        ├── Database/
        │   └── migrations/
        │       └── 2025_08_24_000000_create_blogs_table.php
        └── lang/
    
  3. Run migrations:

    php artisan migrate
  4. Access your module: Visit /blog in your browser!

Configuration

Publish the configuration file (optional):

php artisan vendor:publish --tag=modular-config

This creates config/modular.php:

<?php

return [
    // Directory where modules are stored
    'modules_path' => 'modules',

    // Base namespace for modules
    'namespace' => 'Modules',

    // Whether to prefer module-specific ServiceProviders
    'prefer_module_provider' => true,
];

Module Structure

Each module can contain:

modules/YourModule/
├── YourModuleServiceProvider.php  # Optional custom service provider
├── Http/
│   └── Controllers/               # Controllers
├── routes/
│   ├── web.php                   # Web routes
│   └── api.php                   # API routes (optional)
├── resources/
│   └── views/                    # Blade templates
├── Database/
│   └── migrations/               # Database migrations
├── lang/                         # Translations
├── config/                       # Module-specific config files
└── helpers.php                   # Helper functions (optional)

Examples

Creating a Blog Module

php artisan make:module Blog

Generated controller (modules/Blog/Http/Controllers/BlogController.php):

<?php

namespace Modules\Blog\Http\Controllers;

use Illuminate\Routing\Controller;

class BlogController extends Controller
{
    public function index()
    {
        return view('blog::index');
    }
}

Upgrading from v1.x

Version 2.0 includes several breaking changes:

Requirements

  • PHP: Now requires 8.2+ (was 8.1+)
  • Laravel: Now requires 11.0+ (was 10.0+)

To upgrade:

  1. Update your composer.json to require PHP 8.2+
  2. Update to Laravel 11+
  3. Run composer update dev-sajid/laravel-modular

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-23