Giter Club home page Giter Club logo

php-8-tempa-php's Introduction

icanhazstring/tempa-php

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:
>

...

php-8-tempa-php's People

Contributors

icanhazstring avatar teewurst avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.