定制 vsdesk/vsdesk-builder 二次开发

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

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

vsdesk/vsdesk-builder

Composer 安装命令:

composer require vsdesk/vsdesk-builder

包简介

GUI built on top of Gii, migration tool, and other extensions to quickly prototype and generate working apps

README 文档

README

How it works

It is about two main things:

  • A user interface like a workbench tool to quickly prototype application schema (entities,attributes,relations,..)
  • A list of console commands dynamically generated based on the prototype and executed in terminal. Those commands should do stuff like cleaning DB, create and execute migrations, use Gii to generate models, CRUDs, ...

‼️ IMPORTANT ‼️

This extension is meant to be used with new creations only. If Gii UI has the decency to ask before overriding stuff, this extension won't. Its default Gii console commands are labeled by --interactive=0 and --overwrite=1 flags. So it will literally destroy your DATABASE plus any existing code found on its way.

Installation

Install via composer

php composer.phar require --prefer-dist vsdesk/vsdesk-builder "*"

or by adding

"vsdesk/vsdesk-builder": "*"

to the require-dev section of your composer.json file.

Usage

Once the extension is installed, add it to both web.php and console.php configuration files:

/* preferably to add under 'dev' environment */

if (YII_ENV_DEV) {
   
    $config['bootstrap'][] = 'builder';
    $config['modules']['builder'] = [
        'class' => 'vsdesk\builder\Module',
        /**
	  * Optional Attributes
	  *
	  * 'allowedIPs' => ...
	  * 'yiiScript' => ...
	  * 'dataPath' => ...
	  * 'previewUrlCallback' => ...
	  * 'commands' => ...
	  */
    ]; 
}

You can then access it through the following URL:

http://localhost/path/to/index.php?r=builder

or http://localhost/path/to/index.php/builder depending on your app routing configurations. Also note that it is not required to name the module builder you can use schema-builder or any other name you like.

Once there, create your first schema (ex: admin, v1), set all its related configurations at once (form inputs are organized within different tabs) then click on the created schema to get into its view page and start adding entities (ex: user, book). To each entity you need to add attributes and define relationships if there is any (no need to declare any id or xxx_id columns as those will be auto generated). Once your schema is complete go back to its view page and hit that GENERATE button.

Optional Attributes

allowedIPs: The list of IP adresses allowed to access the builder tool. default to ['127.0.0.1', '::1'].

yiiScript: The path that points to ./yii script. default to @app/yii.

dataPath: Path to store GUI related data and settings. default to 'runtime/schema-builder/data'.

previewUrlCallback: If the preview link doesn't correctly point to your resources, this is where you declare your own function to generate the correct link. see default implementation here.

commands: This is the array holding the list of commands to be dynamically generated. A command can be represented within a simple string, a callable function or a generator:

$commands = [
    // a string example representing the command to be executed
    'yii migrate/up --interactive=0',

    // a callable example returning a command or a list of commands to be executed
    function($schema) {
	// implement your logic here then
	// return either a string or an array of strings
    }

    // a custom generator (where you can also set default form values)
    [
        'class' => 'vsdesk\builder\generators\model\Generator',
        'defaultAttributes' => [
            'ns' => 'api\modules\v1\models',
            'queryNs' => 'api\modules\v1\models',
        ],
    ],
];

Custom generators are required when you need to collect user inputs for settings. A generator should have a form.php file (like gii generators) that will be auto rendered in a separate tab with the schema create/update form. Related inputs will be saved within GUI data.

Default value of $commands is the following:

$commands = [
    ['class' => 'vsdesk\builder\generators\migration\Generator'],
    ['class' => 'vsdesk\builder\generators\module\Generator'],
    ['class' => 'vsdesk\builder\generators\model\Generator'],
    ['class' => 'vsdesk\builder\generators\crud\Generator']
];

Copy any of those classes from the extension and adapt it to your needs when you need to create a custom generator.

Keep in mind when building your own logic that both callable functions as generators have access to the $schema instance being selected. From that instance you can access to all the GUI ActiveRecord classes which are Attribute, Entity and Relationship. Please refer to vsdesk\builder\models folder and see the code for more details.

Other example, an advanced example list of commands could also be seen here which are the related commands for generating working REST resources in the app template I linked before.

Built With

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

vsdesk/vsdesk-builder 适用场景与选型建议

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

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

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

围绕 vsdesk/vsdesk-builder 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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