定制 bakgul/laravel-file-creator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

bakgul/laravel-file-creator

Composer 安装命令:

composer require bakgul/laravel-file-creator

包简介

This package aims to create the app, database, and test files. It can be a replacement for Laravel's file generator because this package offers some quite nice features. It offers extra file types like interface, trait, service, etc. Depending on the settings, it can create dozens of files with a si

README 文档

README

This package aims to create the app, database, and test files. It can be a replacement for Laravel's file generator because this package offers some quite nice features. It offers extra file types like interface, trait, service, etc. Depending on the settings, it can create dozens of files with a single command and connect them to each other properly.

Update to v4

Config

If you didn't make any changes on config/packagify.php, simply delete it and republish the settings. Otherwise, go to vendor/bakgul/laravel-file-creator/config/methods.php, get the array and insert it to packagify.php associated with the key named methods.

Stubs

Controller uses a single stub file, and it generate everything on the fly. If you have custom controller stubs for different variations, you can't use them in this version unless you modify controller.stub and make it work for you.

Service stub is also updated.

What is new?

  • Task base invokable controller has become possible.
  • Controller's methods' arguments, body, and return have become quite detailed and hopefully handy.
  • Services contains basic implementations of their tasks and proper return types.

Installation

If you installed Packagified Laravel, you should have this package already. So skip installation.

composer require bakgul/laravel-file-creator

Next, you need to publish the settings by executing the following command. By doing so, you will have a new file named packagify.php on the config folder. If you check the "files" array, you can see the file types that can be created. Quite deep explanations are provided in the comment block of the files array.

sail artisan packagify:publish-config

After publishing stubs, you will be able to update the stub files as you need. It's safe to delete the unedited files.

sail artisan packagify:publish-stub

Command Signature

create:file {name} {type} {package?} {app?} {--p|parent=} {--t|taskless} {--f|force}

Arguments

  • name: subs/name:task

    • subs: You can specify subfolders like sub1/sub2/sub3 when you need a deeper file structure than the file types path_schema provides.

    • name: The file name without any suffix.

    • task: This is optional.

      • exist: You may set one or more tasks with a dot-separated fashion like "users:index" or "users:index.store.update." The task should be in the file type and its pairs' and the global task lists (see the tasks array on config/packagify.php). Otherwise, it will be ignored.
      • missing: If the underlying file type has tasks, a separate file will be generated for each of them. Otherwise, a single file will be generated.
  • Type: name:variation:mod

    • name: It's required and should be one of the keys in the files array on config/packagify.php except for the view, css, js, livewire, and component. These keys will be used by Laravel Resource Creator. All detailed explanations can be found in the comment block of the files array.

    • variation: It's optional.

      • exist: If the given file type has variations, you may specify which one should be created.
      • missing: The default variation, which is the first item in the variations array, will be used.
    • mod: When a veriation has different mods, you can speciy it here. For example, controller's variations have default and "api" modes. To create an api controller, you should use controller::api and to create a nested api, you should use controller:nested:api.

    • `

  • Package: It won't be used when working on a Standalone Laravel or Standalone Package. If you don't specify a valid package name, the file will be generated in the App namespace.

  • App: Some files, like the controller, may have app-specific. When I say app, I mean admin, web, desktop, etc. To create those files in the dedicated app folder, you must specify the app name. The settings are in the apps array on the config/packagify.php file.

Options

  • Parent: To create a nested controller, a parent model, or to create a listener, a parent event is required. Evaluator will warn you when a parent has to be specified.

  • Taskless: The file types that have tasks like service, or test, will be generated as a separate file for each task unless tasks are specified. But sometimes, you may want to create a single file without any task. In such cases, You need to append "-t" or "--taskless" to your command. This will cancel the default behaviour of the task explosion.

  • Force: Normally, a file will not be regenerated if it exists. If this option is passed, a new file will be created anyway.

Packagified Laravel

The main package that includes this one can be found here: Packagified Laravel

The Packages That Will Be Installed By This Package

bakgul/laravel-file-creator 适用场景与选型建议

bakgul/laravel-file-creator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 125 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 05 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 bakgul/laravel-file-creator 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-17