icanhazstring/tempa-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

icanhazstring/tempa-php

最新稳定版本:2.2.0

Composer 安装命令:

composer require icanhazstring/tempa-php

包简介

Template file parsing library

README 文档

README

Build Status

What for?

You all came across some *.dist or *.skel files of some sort. This library can be used to replace every existing substitute in those files as well as simply list them.

Install

To install this library simply use composer.

$ composer require icanhazstring/tempa-php

After you have done this you need to create a tempa.json file inside you project. This file holds some basic information about the template files.

Here is an example

{
  "fileExtensions": ["dist", "skel"],
  "prefix": "{$",
  "suffix": "}"
}

Usage

Scan

You can scan a directory or single file using the scan command.

$ vendor/bin/tempa file:scan <dir> [<config>]

You can deliver every other config you want. By default the script will take the tempa.json from the location you executed the script.

$ vendor/bin/tempa file:scan test/Demo
$ vendor/bin/tempa file:scan test/Demo test/Demo/tempa.json

Scanning for template files in: /home/icanhazstring/tempa-php/test/Demo
=======================================================================

 2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


/home/ando/tempa-php/test/Demo/Sub/test.php.dist
------------------------------------------------

Line 3 : 'database' => '{$database}',
Line 4 : 'username' => '{$user}'

/home/ando/tempa-php/test/Demo/test.php.dist
--------------------------------------------

Line 3 : 'placeholder' => '{$superAwesome}'

Substitute

To replace stuff run the following:

$ vendor/bin/tempa file:substitute [-f|--mapfile [MAPFILE]] [--] <dir> [<config>] [<map>]... 
$ vendor/bin/tempa file:substitute test/Demo/
$ vendor/bin/tempa file:substitute test/Demo/ --mapfile=test/Demo/maps/map.[json|php]
$ vendor/bin/tempa file:substitute test/Demo/ test/Demo/tempa.json database=localhost user=icanhazstring superAwesome=mega 

Processing template files in: /home/icanhazstring/tempa-php/test/Demo
=====================================================================

 2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

Interactive

You can replace every with an interactive mode:

$ vendor/bin/tempa file:interactive test/Demo
$ vendor/bin/tempa file:interactive test/Demo test/Demo/tempa.json


Interactive substitution for template files in: /home/icanhazstring/tempa-php/test/Demo
=======================================================================================

Found 3 substitutes
-------------------

database:
>

...

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-02