/php-requirejs-modules

A tool for loading RequireJS modules with configuration from within PHP

Primary LanguagePHPMIT LicenseMIT

php-requirejs-modules

A tool for loading RequireJS modules with configuration from within PHP

Usage:

Inclusion

<?php

include("RequireJSModules.php");

$requirejs_config = array();
$javascript_dir = "js";

$modules = new RequireJSModules($requirejs_config, $javascript_dir);
$modules->load("moduleName", array(
  "moduleOption" => "value",
  "anotherModuleOption" => "anotherValue"
));
$modules->load(array(
  array(
    "file" => "moduleName",
    "options" => array(
      "moduleOption" => "value",
      "anotherModuleOption" => "anotherValue"
    )
  ),
  array(
    "file" => "anotherModule",
    "options" => array(
      "moduleOption" => "value",
      "anotherModuleOption" => "anotherValue"
    )
  ),
));
$modules->load("moduleName", array(
  array(
    "moduleOption" => "value",
    "anotherModuleOption" => "anotherValue"
  ),
  array(
    "moduleOption" => "value",
    "anotherModuleOption" => "anotherValue"
  ),
));
echo $modules->output();

View Documentation