承接 ronasit/larabuilder 相关项目开发

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

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

ronasit/larabuilder

Composer 安装命令:

composer require ronasit/larabuilder

包简介

A great tool for creating and modifying PHP classes in Laravel, providing utilities to generate boilerplate code, add methods, properties, and annotations with ease.

README 文档

README

Coverage Status

Laravel Builder

For internal architecture and contributor guidance, see ARCHITECTURE.md.

Installation

composer require ronasit/larabuilder --dev

Usage

The logic of the package usage consists of the three stages:

  1. Open a php file
  2. Call required class modifications methods
  3. Render modified class structure and overwrite existing file
new PHPFileBuilder(app_path('Models/User.php'))
    ->addArrayPropertyItem('fillable', 'is_active')
    ->setProperty('casts', [
        'is_active' => 'boolean',
    ], AccessModifierEnum::Protected)
    ->save();

Features

setProperty

Add new class property with the passed value and passed access level in case property does not exist in the class. Otherwise will change already existing class property's value AND access level

addArrayPropertyItem

Add new item to the array class property. Will add new property in case it does not exist yet.

removeArrayPropertyItem

Remove items from the array class property. If the property or item does not exist no action is taken.

insertCodeToMethod

Insert the provided code into the specified method body at the desired position - by default, to the end of the method.

addImports

Add new imports to the file. This method will add a new import only in case it does not exist yet, preventing duplicate use statements.

addTraits

Add new use TraitName; statements to a class, trait, or enum. This method automatically adds the corresponding use imports at the top of the file and prevents duplicate trait usages.

Note: Need to provide the full trait class name (FQCN); the method will import it automatically.

addMethod

Add a new method to a class, trait, or enum. Throws NodeAlreadyExistsException if a method with the given name already exists.

new PHPFileBuilder(app_path('Http/Controllers/UserController.php'))
    ->addMethod(
        name: 'delete',
        code: '
            $service->delete($id);
            return response()->noContent();
        ',
        params: new MethodParamsList(
            new MethodParamDTO(name: 'request', type: 'DeleteRequest'),
            new MethodParamDTO(name: 'service', type: 'UserService'),
            new MethodParamDTO(name: 'id', type: 'int'),
        ),
        returnType: 'Response',
    )
    ->save();

removeMethod

Remove a method by name from a class, trait, enum, or interface.

Special Laravel structure builders

Bootstrap app

To modify the Laravel bootstrap app file, use special AppBootstrapBuilder:

new AppBootstrapBuilder()->addExceptionsRender(ExpectationFailedException::class,  '
    throw $exception;
')->save();

This builder has all the features described above and the special methods:

addExceptionsRender

Adds a new exception render to the withExceptions called method in case it does not exist yet. Does not modify already added render for the passed exception class.

Note Need to provide the full exception class name (FQCN) to the method, it automatically imports it.

Contributing

Thank you for considering contributing to Laravel Builder package! The contribution guide can be found in the Contributing guide.

License

Laravel Builder package is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固