laravins/template-file-generator
Composer 安装命令:
composer create-project laravins/template-file-generator
包简介
File generator from template with data customization.
README 文档
README
Introduction
This package allows you to generate files based on template with data customization.
Installation
composer require laravins/template-file-generator
This will install the package inside your project and setup example files.
Config filelocated atconfig/template-file-generator/example-generator.phpTemplate fileslocated atresources/template-file-generator/example-generator/crud-views
Config file
This config file will:
-
Use template folder located at
projet_path/resources/template_file-generator/example-generator/crud-views -
Generate two files
list.blade.phpandedit.blade.phpinproject_path/resources/views/users. -
Replace each occurences of
%thanks%byThanks for using this package 👌of generatedlist.blade.phpfile. -
Replace each occurences of
%stars%byRoad to 50 ⭐of generatedlist.blade.phpfile. -
Replace each occurences of
%heart%by❤️of generatededit.blade.phpfile. -
Replace each occurences of
%dev_attitude%bylazyof generatededit.blade.phpfile.
<?php return [ 'files' => [ // Put here the list of files 'list.blade.php' => [ // Put here variables to replace 'thanks' => 'Thanks for using this package 👌', 'stars' => 'Road to 50 ⭐', ], 'edit.blade.php' => [ 'heart' => '❤️', 'dev_attitude' => 'lazy', ] ], 'config' => [ // Path of your template folder 'base_path' => 'template-file-generator/example-generator/crud-views', // Prefix of template folder path. Please, refer to prefixes section 'base_path_prefix' => 'resource', // Path of your target generated folder 'target_path' => 'views/users', // Prefix of template folder path. Please, refer to prefixes section 'target_path_prefix' => 'resource' ], ];
Prefixes
Allowed prefixes used for base_path_prefix and target_path_prefix are:
| Prefix | Target |
|---|---|
| app | app_path() |
| base | base_path() |
| config | config_path() |
| resource | resource_path() |
| database | database_path() |
| lang | lang_path() |
| public | public_path() |
| storage | storage_path() |
Template files
You need to set variables that you want to be replaced in % delimiter like %var_to_change_%.
<p>Made with %heart%</p> <p>For %dev_attitude% developers</p>
This will be converted into
<p>Made with ❤️</p> <p>For lazy developers</p>
Usage
use Laravins\TemplateFileGenerator\TemplateFileGenerator; // The path of my config file is actually 'config/template-file-generator/example-generator' $generator = new TemplateFileGenerator('template-file-generator/example-generator'); // Generate files $result = $generator->replaceContent(); // Get result dd($result) // ["status' => "success", "message" => ""] // If an error occurs, please refer to the "message" error.
Artisan command
php artisan laravins-tfg:generate template-file-generator/example-generator
Thanks ✌️
laravins/template-file-generator 适用场景与选型建议
laravins/template-file-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 4, 最近一次更新时间为 2023 年 01 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 laravins/template-file-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 laravins/template-file-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-19