madflow / cheesecake
从模板创建项目或目录结构
3.1
2024-02-21 09:45 UTC
Requires
- php: ^7.4||^8.0
- cypresslab/gitelephant: ~3.0
- docopt/docopt: 1.0.0
- mustache/mustache: ^2.9
- symfony/filesystem: ^3.4||^4.4||^5.0
- symfony/finder: ^3.4||^4.4||^5.0
- symfony/process: ^3.4||^4.4||^5.0
- wp-cli/php-cli-tools: ^0.10.5
Requires (Dev)
- phpunit/phpunit: ^9.6.15
This package is not auto-updated.
Last update: 2024-09-11 15:21:52 UTC
README
Cheesecake 是一个用于 PHP 的项目/目录骨架生成工具。它受到 https://github.com/audreyr/cookiecutter 的启发。
安装
$ composer require madflow/cheesecake
$ ./vendor/bin/cheesecake
在不使用命令行的情况下使用它
$template = __DIR__ .'/mytemplate'; $output = __DIR__ .'/myoutput'; $params = ['project_name' => 'Yeah!']; $options = [ Generator::OPT_OUTPUT => $output, Generator::OPT_NO_INTERACTION => true, ]; $o = new Generator($template, $params, $options); $o->run();
开发
# Clone the repo
git clone https://github.com/madflow/cheesecake.git
# Install dependencies
cd cheesecake
composer install
示例
创建一个 Silex 入门项目
# Create output directory
mkdir /tmp/silex
# Mmmh - Cheesecake
./bin/cheesecake -o /tmp/silex examples/silex-starter
钩子
将钩子放在 hooks
目录中,并命名为 pre_gen.php
或 post_gen.php
。
技巧
- 在处理 Twig 模板时,Mustache 引擎会尝试解释如
{{ okay | upper }}
这样的表达式,并将失败并抛出Mustache_Exception_UnknownFilterException: Unknown filter: upper
。 - 为了绕过这个问题,你可以在你的
cheesecake.json
文件中定义一个魔法filters_ignore
参数。
{
"app_name": "twig",
"filters_ignore": ["upper"]
}
filters_ignore
接受一个字符串数组,这些字符串将被转换为虚拟过滤器。
- 你可以始终尝试更改分隔符,如在此处文档中所述: https://github.com/bobthecow/mustache.php/wiki/Mustache-Tags#set-delimiter
- 这样应该可以绕过其他模板引擎的问题。