Requirejs helper for CakePHP

Installs: 825

Dependents: 3

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 2

Open Issues: 0


0.2.2 2016-02-22 02:44 UTC

This package is not auto-updated.

Last update: 2021-10-30 02:24:44 UTC


Build Status Packagist Software License

Require plugin for CakePHP

Load javascript modules (AMD) asynchroneously from anywhere in your views via requirejs.


Install the plugin using composer.

"gintonicweb/requirejs": "~0.2"

Load it in config/bootstrap.php



Load this helper from your controller and define your config options.

  • require the basepath where requirejs library can be found (optional)
  • configFiles requirejs configuration files (optional)
  • inlineConfig inline configuration options, echoed as an inline config file (optional)
public $helpers = [
    'Requirejs.Require' => [
        'require' => 'myrequire',
        'configFiles' => [
        'inlineConfig' => [
            'baseUrl' => '/',
            'urlArgs' => 'bust=0',

Here's how load javascript modules. CakePHP plugin notation is supported. When no plugins are defined, the module name is passed as-is to requirejs, allowing you to handle the path the way you like in your own config.js. Once in your template, call load() to load the requirejs lib. It's also possible to pass an array of additional config modules to the load method if needed.

<?= $require->module('') ?>
<?= $require->module('test/demo') ?>
<?= $require->load() ?>