phrep

phrep
Login

PHP Macro Preprocessor

phrep is a command-line macro preprocessor for PHP code.

It's intended as static configuration tool...

Usage

Preprocessing a source script is as simple as:

 phrep -i config.src -o config.php -D PKG_USE_SQLITE=1

Where source files might look (well, in complex cases) like this:

 <?php
 #if __PHP_VERSION__ >= 5.4 && defined(PKG_USE_SQLITE)
  #pragma(dirs=./includes)
  #include <sqlite.ph>
 #else
     include("./lib/basic_db.php");
  #ifdef PKG_DB_EXTENSION
     $db->option = PKG_DB_EXTENSION;
  #endif
 #endif

Most preprocessor constants are just meant for conditional sectioning. But they can also be substituted in PHP code blocks. Just like macros such as HTML@(<a link="$var">…) or even PARAMETERIZE@(select :$x FROM y WHERE z=$z).

Status

Download