承接 ifo/laravel-make-packager 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ifo/laravel-make-packager

Composer 安装命令:

composer require ifo/laravel-make-packager

包简介

README 文档

README

This package is a CLI tool that helps you build a fully structured package for a Laravel application without spending a lot of time. You no longer need to struggle with initializing the skeleton for your package. Instead, focus on writing the source code while Laravel Packager organizes the package structure for you.

Step 0: Pre-Installation Setup

Before installing, please add the necessary file to your root project. You can find the file and instructions at the following link:

Custom Route Provider Setup

Step 1: Install the Package

Run the following command to install the package:

composer require ifo/laravel-make-packager

Step 2: Dump Autoload

After installing the package, run the following command to autoload the package:

composer dump-autoload

The package has been successfully installed.

How to Create a Custom Package

Step 1: Create a New Package

Run the following command to create a new package:

php artisan package:make YourPackageName

This command will create the folder structure and necessary files for your package, including routes, ServiceProvider, and an AbstractController for enforcing rules and validations.

You can refer to the screenshot below:

Package Structure

Folder Structure

Here’s what the folder structure will look like:

--> packageName
    --> composer.json
    --> module.json
    --> src
        --> Config
        --> Console
        --> Database
        --> Events
        --> Http
            --> Controllers
                --> AbstractController // For rules and validations, extends in controllers
                --> PackageNameController
            --> Middleware
            --> Requests
        --> Jobs
        --> Listeners
        --> Models
        --> Providers
            --> ModuleServiceProvider
            --> RouteServiceProvider
        --> Resources
        --> routes
            --> V1.php
            --> web.php
        --> Test
            -->Unit
            -->Feature

Step 2: Register the Package

To register the package, follow the setup steps below:

Step 1: Create Package Directory

Create a packages folder and move the MakePackager directory inside it.

Step 2: Update Composer Autoload

Add the package namespace to the composer.json file under the psr-4 key:

"autoload": {
   "psr-4": {
      "Packages\\MakePackager\\": "packages/MakePackager/src"
   }
}

Step 3: Register the Service Provider

  • For Laravel version below 10: Register the ServiceProvider in the config/app.php file inside the providers array:

'providers' => [
    Packages\MakePackager\Providers\MakePackagerServiceProvider::class,
]
  • For Laravel version 10 and above: Register the ServiceProvider in the app/Providers/AppServiceProvider.php file in the register method:

public function register(): void
{
    $this->app->register(CustomPackageServiceProvider::class);
}

Step 4: Initial Setup Completion

Run the following commands to complete the setup:

composer dump-autoload
php artisan config:cache
php artisan config:clear

Adding Middleware

If you want to automatically apply middleware authentication, add the CustomRouteServiceProvider. This will ensure that the middleware is added by default.

If you prefer not to use the custom middleware setup, you can remove the extension of CustomRouteServiceProvider and instead extend ServiceProvider directly.

MakePackager Artisan Commands

Here are a few custom artisan commands to create specific packages:

php artisan package:make-job YourFileName YourPackageName

to create jobs for a specific package

php artisan package:make-migration YourFileName YourPackageName

to create migration files for a specific package

php artisan package:make-listener YourFileName YourPackageName

to create listeners for a specific package

php artisan package:make-event YourFileName YourPackageName

to create events for a specific package

sudo php artisan package:make-test SamleTest Myo --feature

This command creates a test file in a specific package.

  • First Argument (FileName): The name of the test file you want to create.

  • Second Argument (PackageName): The name of the package where the test file will be placed.

  • Third Argument (--feature): An optional flag. If provided, the test file will be created under the Feature folder. If omitted, the test file will be created under the Unit folder by default.

This package has an additional feature: it will automatically register the test and unit scripts in the root project’s phpunit.xml file, allowing them to be executed smoothly.

More artisan commands will be added in future updates.

ifo/laravel-make-packager 适用场景与选型建议

ifo/laravel-make-packager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.32k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 04 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 ifo/laravel-make-packager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ifo/laravel-make-packager 我们能提供哪些服务?
定制开发 / 二次开发

基于 ifo/laravel-make-packager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-26