staempfli/universal-code-generator

此包已被弃用且不再维护。未建议替代包。

Staempfli AG - 通用代码生成工具

安装: 3,521

依赖: 1

建议者: 0

安全性: 0

星星: 5

关注者: 4

分支: 3

开放问题: 0

类型:staempfli-tool

1.2.4 2019-11-22 19:12 UTC

This package is auto-updated.

Last update: 2020-09-16 12:11:37 UTC


README

Project Status: Abandoned – Initial development has started, but there has not yet been a stable, usable release; the project has been abandoned and the author(s) do not intend on continuing development.

此工具可以用作创建特定框架代码生成器的基座

用法

  1. 创建您自己的生成器项目

  2. 将此项目作为依赖项添加

    composer require "staempfli/universal-code-generator":"~1.0"
    composer update
    
  3. 复制所需的默认配置文件

    • $ cp vendor/staempfli/universal-code-generator/config/default-properties.yml.dist config/default-properties.yml
  4. 您需要创建一个PHP脚本来定义控制台应用程序

    • 我们建议在 bin 文件夹中这样做

      cd bin && vim <command_name>

    • 将以下内容添加到此文件

    #!/usr/bin/env php
    <?php
    $composerAutoload = __DIR__ . '/../../../autoload.php';
    
    if (file_exists($composerAutoload)) {
        require_once $composerAutoload;
    } else {
        require_once __DIR__ . ' /../vendor/autoload.php';
    }
    
    /**
    * Shortcut constant for the project root directory
    */
    define('BP', dirname(__DIR__));
    /**
    * Command name
    */
    define('COMMAND_NAME', basename(__FILE__));
    
    // Init Console Application
    use Staempfli\UniversalGenerator\Application;
    
    $application = new Application('@git-version@');
    
    /**
    * You can add new commands or extend exiting ones to add custom functionality
    * - Check default commands in Staempfli\UniversalGenerator\Application
    * - To add or extend commands you must use the method $application->addGeneratorCommand
    */
    // $application->addGeneratorCommand('template:generate', 'VendorName\ProjectName\Command\TemplateGenerateCommand');
    
    $application->run();
    
  5. 通常您可能想要扩展默认的 template:generate 命令。您可以按以下方式操作

  6. 创建将生成的模板

先决条件

  • PHP >= 5.6.*

开发者

许可证

GNU通用公共许可证,版本3(GPLv3)

版权

(c) 2016 Staempfli AG