BENCODER v - Encode your PHP script using bcompiler


About bencoder

bencoder is a script to automate the encoding task using bcompiler.

bcompiler has the capability to encode entire script in a proprietary PHP application.

But the encoding task needs to be done manually, by calling the functions provided by bcompiler,
such as bcompiler_write_header(), bcompiler_write_file() and bcompiler_write_footer() functions.

bencoder can do these for you, it's very similar to the encoder script provided by eAccelerator.

bencoder is an open source software. It applies GPL license.


Revision History

v1.6 - 2012/01/02 - improve error handling
v1.5 - 2011/12/06 - minor updates
v1.4 - 2010/04/01 - support bcompiler_set_filename_handler() for v0.9.2 (thanks Erwan Corvellec)
v1.3 - 2006/11/07 - support bzip2 compression (thanks to Paul Mandalka)
v1.2 - 2006/08/08 - support recursive mode
v1.1 - 2006/07/25 - first public release


Usage
bencoder [-f] [-q] [-t] -o FILE    file1.php
bencoder [-f] [-q] [-t] -o OUTDIR  file1.php file2.php ...
bencoder [-f] [-q] [-t] -o OUTDIR  -s SRCDIR  [-e SUFFIX] [-r] [-c] [-l]

  -o FILE   : the file name to write the encoded script
              (default to '-encoded.XXX' suffix)
  -o OUTDIR : the directory to write all encoded files

  -s SRCDIR
  -a SRCDIR : encode all files from this source directory

  -r        : encode directories recursively (no by default)
  -f        : force overwriting even if the target exists
  -t        : truncate/keep only the basename of the file into the bytecode
  -e SUFFIX : encode the files with the SUFFIX extension only (default: php)
              (regular expression allowed, ex: "php|inc")
  -c        : copy files those shouldn't be encoded (no by default)
  -l        : follow symbolic link (no by default)
  -q        : do not print the file name while encoding or copying
  -b
  -bz2      : compress the encoded files with bz2 (needs bzip2-extension)

Prerequisite
  1. Install bcompiler (the most updated version is )
    # pecl install channel://pecl.php.net/bcompiler-
  2. Install PHP bzip2-extension if you need bz2 compression

Installation
  1. Download the script from http://bencoder.urdada.net/bencoder
    # wget http://bencoder.urdada.net/bencoder
  2. Turn on the execution permission bit on the script
    # chmod 755 bencoder
  3. Copy the script to /usr/local/bin/ or somewhere else in your PATH
    # cp bencoder /usr/local/bin/
  4. Run it and get an usage help
    # bencoder

Limitation

Reference
Author
Shen Cheng-Da
cdsheen at gmail.com