PHP Application for build html, css, less, js files to one file
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

PHP RIA Builder

PHP Application for build html, css, less, js files to one file. Is very simplify method for compiling JavaScript application for production.

What is it, example

Suppose we have a simple application

body {
    color: red;

function a(message) {

Create package.json for build

    "include": [
            "type": "css",
            "files": [
            "browser": "ie <9"

Build package, for example through the console

/var/www/riabuilder/run -c testapp

Compile result

if (RIABuilder.matchBrowser("ie <9")){RIABuilder.appendStyle("body {color: red;}");} function a(m) {alert(m);}


  • Supported formats: js, css, less, html
  • Server-side compile less to css
  • Compress js, css and html
  • Include js/css/template by browser condition
  • Dynamic build and return package
  • Build package from command line
  • Manually load packages from frontend

How to use

Create package.json file

Package (or module) - is a directory with package.json file, which has configuration for building application. See package.json format example:

    // Main section - include
    "include": [
        // Full format (for types: js, css, less, template)
            // One of file type: js, css, less, template, module
            "type": "js",

            // List of included files
            "files": [

            // Wrap javascript included files in anonymous function? Default: false
            "wrap": false,

            // Wrap each javascript file in anonymous function? Default: false
            "wrapEach": true,

            // Browser condition, format:
            //   "browser [comparison][version]"
            //   - browser One of values: ie, chrome, safari, opera, firefox, ...
            //   - comparison Sing comparison: >=, <=, >, <, =
            //   - version Number of version
            // Examples:
            //   - ie 8
            //   - firefox >10.2
            //   - opera
            "browser": "ie <9"

        // Full format (for type: module)
            "type": "module",

            // Relative path to module dir or package.json file
            "path": "module/customapp",

            // Set this params as default for module
            "wrap": false,
            "wrapEach": true

        // Load css only for ie < 9
            "type": "css",
            "files": [
            "browser": "ie <9"

        // Short format for load one file. Type autodetect by extension `js`.

        // Short format for load templates. This item will be loaded all templates
        // in module dir and it sub dirs. Type auto detected by extension `html`.

        // Will be loaded and convert to css all less files from dir less.

Build from console


run.bat [-c][-p] modulePath [savePath]


  • -c or --useCompress Enabled compress js, css and html for production mode
  • -p or --rootPath Absolute path to root of javascript applications


  • modulePath Relative path to module dir or package.json file. Examples: dir, dir/subdir, dir/mypackage.json. If set dir, then by default will be fined file package.json.
  • savePath (optional) Relative path to save file. By default will be used modulePath without special chars. Example: dir/testapp -> dir_testapp.js.

Run commands:

C:\www\riabuilder\run.bat -c testapp test_min.js

/var/www/riabuilder/run -c testapp test_min.js

Dynamic build and echo to browser

You can create PackageBuilder instance and manually build package. PackageBuilder - is a main class with global configurations:

  • rootPath Absolute path to root of javascript applications. Relative to that directory will be searched you modules.
  • useCompress Enable compressing js, css and html.
  • method readModule Scan module package.json, require all resources and returned JavaScript code.



require_once __DIR__ . '/../riabuilder/PackageBuilder.php';


$packageBuilder = new \riabuilder\PackageBuilder();
$packageBuilder->rootPath = __DIR__;
//$packageBuilder->useCompress = true;

header('Content-Type: text/javascript; charset=UTF-8');
echo $packageBuilder->readModule('testapp');


  • Server: PHP 5.3 or latest
  • Client: Tested on browsers ie >8 and last versions of opera, chrome, safari, firefox