<h1>PHP Macro Preprocessor</h1>

<kbd>phrep</kbd> is a command-line **macro preprocessor** for PHP code.
<img src=logo width=133 height=144 align=right style=margin:25pt

  * It handles C-style [processing directives](wiki/directives) like `#define`,
    `#include`, `#if`, `#ifdef`, `#elif`, `#else`, `#endif`, `#undef`,
    `#pragma`, `#stderr`, `#srcout`.
  * Applies constants and standard [macro substitutions](wiki/macro) only
    within code sections.
  * Also allows more [complex](wiki/complex) MACRO@() transformations per PHP
    inline callbacks.
  * Is somewhat compatible with [cpp / preprocess / phpp](wiki/alternatives),
    can read C header `.h` files.
  * Otherwise leaves comments and code structure intact.

It's intended as static configuration tool[...](wiki/use+cases)

  * Can be used within trivial [makefiles](wiki/makefiles), or slim packaging scripts.
  * Useful for simple code templating or one-off generation tasks.
  * And reduces runtime softcoding, as it allows code-embedded feature branches.

### Usage

Preprocessing a source script is as simple as:

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

Where [source](wiki/file+extensions) files might look like this:

     <?php
     #if __PHP_VERSION__ >= 5.4 && defined(PKG_USE_SQLITE)
      #pragma(dirs=./includes)
      #include <sqlite.ph>
     #else

      #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($var)` or even $x FROM $y)`.

### Status

  * Experimental / development
  * Command line <kbd>-flags</kbd> don't completely map all
    [#pragma directives](wiki/pragma) yet.
  * [#if expressions](wiki/expressions) are mostly usable already.
  * No [composer-plugin](wiki/composer-plugin) yet defined.
  * A [man page](wiki/manpage) exists.

### Download

  * Use the [zip](zip/phrep.zip?uuid=trunk) or [tar](tarball/phrep.tgz?uuid=trunk)
    for literal sources.
  * Get the combined [*phrep*
  * Or install <kbd>phrep</kbd> per
    <a class=download /
    <a class=download
    directly.
  * Updates are announced via


<style>
.download {
  background: linear-gradient(180deg, #66DD55, #448822);
  border: 1px solid #449933;
  color: #FFFFFF;
  text-shadow: 0px 1px 0px #888888;
  border-radius: 5px;
  font-weight: 500;
  font-size: 115%;
  margin: 2pt;
  padding: 2pt 5pt;
}
</style>