brstreet2/laracrud 问题修复 & 功能扩展

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

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

brstreet2/laracrud

Composer 安装命令:

composer require brstreet2/laracrud

包简介

A Laravel package for generating API CRUD functionality

README 文档

README

LaraCRUD is a Laravel package designed to streamline the creation of API CRUD (Create, Read, Update, Delete) operations. It automates the generation of models, controllers, migrations, factories, routes, and more, enabling developers to focus on building features instead of repetitive boilerplate code.

Inspiration
This package was inspired by the efficient workflows and best practices advocated at my workplace. Special thanks to my engineering manager for the insightful guidance and the foundational idea behind LaraCRUD.

Features

  • Generates Eloquent models with optional migrations.
  • Creates API controllers with full CRUD functionality, including validation requests.
  • Sets up API routes automatically with customizable naming conventions.
  • Produces factories for model testing.
  • Generates feature tests for the API CRUD operations.
  • Supports interactive prompts for missing components.
  • Leverages customizable stubs for controllers, requests, and tests.

Installation

Install the package via Composer:

composer require brstreet2/laracrud --dev

If you prefer to install it globally:

composer global require brstreet2/laracrud

Usage

To generate CRUD operations for a specific model:

php artisan brstreet:api-crud {ModelName}

If the model does not exist, the command will prompt you to create it along with an optional migration.

Example

Generating CRUD for a Post model:

php artisan brstreet:api-crud Post

Files and Routes Created

  1. Model

    • File: app/Models/Post.php
    • If the model does not exist, the command will generate a new model.
  2. Controller

    • File: app/Http/Controllers/Api/PostController.php
    • A full-featured controller is created under the Api namespace.
  3. Migration

    • File: database/migrations/xxxx_xx_xx_create_posts_table.php
    • If no migration exists for the table, a new migration file is created.
  4. Factory

    • File: database/factories/PostFactory.php
    • A factory is created to support testing and seeding the model.
  5. Routes

    • Added in routes/api.php:
      Route::apiResource('posts', PostController::class)->names('posts');
    • The route path uses plural kebab case (posts), and route names are in plural snake case (posts.index, posts.store, etc.).
  6. Request Classes (generated if the controller is created)

    • Files:
      • app/Http/Requests/Post/IndexRequest.php
      • app/Http/Requests/Post/CreateRequest.php
      • app/Http/Requests/Post/UpdateRequest.php
    • These handle validation and permissions for API actions.
  7. Resource Class

    • File: app/Http/Resources/PostResource.php
    • Encapsulates the model data for API responses.
  8. Feature Test

    • File: tests/Feature/PostControllerTest.php
    • A test file is generated to validate the API's behavior.

Contributing

Contributions are welcome! Please fork the repository and submit a pull request.

License

This project is open-sourced software licensed under the MIT license.

Credits

  • Developed by brstreet2
  • Inspired by the engineering practices at my workplace, with special thanks to my engineering manager for the foundational idea.

brstreet2/laracrud 适用场景与选型建议

brstreet2/laracrud 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 05 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 brstreet2/laracrud 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-10