shah-newaz/redprint-ng 问题修复 & 功能扩展

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

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

shah-newaz/redprint-ng

Composer 安装命令:

composer require shah-newaz/redprint-ng

包简介

Laravel CRUD Generator

README 文档

README

A Laravel package for generating CRUD operations with Vue.js frontend integration.

NOTE: Redprint is extremely opinionated about how you should structure your Laravel + Vue 3 project. It is designed to be used with Laravel 11+ and Vue 3+ using Element Plus and Tailwind CSS.

This package is still in development and may not be fully stable.

Installation

composer require shah-newaz/redprint-ng

Publish the configuration:

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

Requirements

  • PHP 8.2+
  • Laravel 11+
  • Vue.js 3
  • The following npm packages must be installed in your project:
    • tailwindcss
    • element-plus
    • axios
    • vue
    • vue-router
    • vue-i18n
    • lodash-es

Configuration

The package will look for your Vue router configuration file at the specified location relative to the resources directory. Make sure this path is correctly set before running the CRUD generator command.

config/redprint.php

return [
    /*
    |--------------------------------------------------------------------------
    | Axios Instance
    |--------------------------------------------------------------------------
    |
    | Specify the axios instance to be used in Vue components.
    | Example: 'this.$api' will generate this.$api.get() instead of axios.get()
    | Set to null to use a local axios instance with proper baseURL.
    |
    */
    'axios_instance' => null,
    
    /*
    |--------------------------------------------------------------------------
    | Vue Router Location
    |--------------------------------------------------------------------------
    |
    | Specify the location of your Vue router configuration file.
    | This should be relative to the resources directory.
    | Example: 'js/router/routes.ts' or 'js/router.js'
    |
    */
    'vue_router_location' => 'js/router/routes.ts',
];

Commands

Generate CRUD

php artisan redprint:crud

It will prompt you for the model name, namespace, route prefix, soft deletes, and layout.

Example:

php artisan redprint:crud```

This will generate:
- Model (`app/Models/Product.php`)
- Controller (`app/Http/Controllers/Api/ProductController.php`)
- Resource (`app/Http/Resources/ProductResource.php`)
- Migration (`database/migrations/xxxx_xx_xx_create_products_table.php`)
- Vue Components:
  - `resources/js/pages/Product.vue`
  - `resources/js/components/Product/Index.vue`
  - `resources/js/components/Product/Form.vue`
- API Routes in `routes/api.php`
- Common Components (if not exist):
  - `resources/js/components/Common/Empty.vue`
  - `resources/js/components/Common/FormError.vue`
  - `resources/js/components/Common/InputGroup.vue`

### Generate Vue Component
```bash
php artisan redprint:vue

This command allows you to generate three types of Vue components:

  1. Blank Component: A basic Vue component with minimal setup
  2. List Component: A data table component with search, sort, and pagination
  3. Form Component: A form component with validation and API integration

Usage Examples:

Blank Component:

php artisan redprint:vue
# Select 'blank' when prompted
# Enter component path (e.g., @/components/views/MyComponent.vue)

List Component:

php artisan redprint:vue
# Select 'list' when prompted
# Enter API endpoint (e.g., api/v1/products)
# Define columns when prompted
# Enter component path (e.g., @/components/views/ProductList.vue)

Form Component:

php artisan redprint:vue
# Select 'form' when prompted
# Enter API endpoint (e.g., api/v1/products)
# Define columns and relationships when prompted
# Enter component path (e.g., @/components/views/ProductForm.vue)

Column Definitions

When creating list or form components, you'll be prompted to define columns. Each column can have:

  • Name: The field name (e.g., 'title')
  • Type: Data type (string, text, boolean, integer, etc.)
  • Nullable: Whether the field is required
  • Relationship Data (optional): For form components with related models
    [
        'endpoint' => 'api/v1/categories/list',
        'labelColumn' => 'name',
        'relatedModelLower' => 'categories'
    ]

Generated Components

Blank Component:

  • Basic Vue 3 component structure
  • Script setup syntax
  • TypeScript support

List Component:

  • Element Plus data table integration
  • Search functionality
  • Pagination
  • Column sorting
  • Delete/restore actions (if soft deletes enabled)
  • API integration with configured axios instance

Form Component:

  • Form validation
  • Dynamic input types based on column definitions
  • Related model select inputs (with API integration)
  • Save/update functionality
  • Error handling
  • Loading states

All components are generated with TypeScript support and follow Vue 3's composition API patterns.

Generated API Routes

The following API routes will be generated for each CRUD:

Route::prefix('v1')->middleware(['auth:api'])->group(function () {
    Route::get('products', [ProductController::class, 'getIndex']);
    Route::get('products/{id}', [ProductController::class, 'show']);
    Route::post('products/save', [ProductController::class, 'save']);
    Route::delete('products/{id}', [ProductController::class, 'delete']);
    // If soft deletes enabled:
    Route::delete('products/{id}/force', [ProductController::class, 'deleteFromTrash']);
});

Vue Router Integration

The generated components will automatically integrate with Vue Router, providing the following routes:

{
    path: '/products',
    name: 'pages.products',
    component: ProductPage,
    children: [
        {
            path: '',
            name: 'pages.products.index',
            component: ProductIndex,
            meta: {title: 'routes.titles.products', description: 'routes.descriptions.products', requiresAuth: true},
        },
        {
            path: 'edit',
            name: 'pages.products.edit',
            component: ProductForm,
            meta: {title: 'routes.titles.edit_product', description: 'routes.descriptions.edit_product', requiresAuth: true},
        },
        {
            path: 'new',
            name: 'pages.products.new',
            component: ProductForm,
            meta: {title: 'routes.titles.new_product', description: 'routes.descriptions.new_product', requiresAuth: true},
        },
    ],
}

License

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

shah-newaz/redprint-ng 适用场景与选型建议

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

它主要适用于以下技术方向: 「code generation」 「api」 「crud」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 shah-newaz/redprint-ng 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-11