Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

dotphp

uniter12MIT3.9.0

Require PHP files under Node.js with Uniter

php, uniter

readme

DotPHP

Build Status

Require PHP files from Node.js with Uniter.

Installing

npm install --save dotphp

Hooking Uniter into require(...)

You can install a custom require(...) extension that will use Uniter to compile the specified PHP file to JS and include it.

Example:

PHP file my_module.php:

<?php

print 'Hello from my_module!';

JS file my_entrypoint.js:

// Register the extension for requiring .php files
require('dotphp/register')().then(() => {
    require('./my_module.php')().execute();
});

Requiring PHP files without hooking require(...)

You can also require PHP files without interfering with require(...) behaviour by using the <DotPHP>.require(...) method.

Example:

PHP file my_module.php:

<?php

print 'Hello from my_module!';

JS file my_entrypoint.js:

require('dotphp').require('./my_module.php')().execute();

Keeping up to date

changelog

CHANGELOG

3.0.0

  • The method getListenerPriority($eventName, $listener) has been added to the EventDispatcherInterface.
  • The methods Event::setDispatcher(), Event::getDispatcher(), Event::setName() and Event::getName() have been removed. The event dispatcher and the event name are passed to the listener call.

2.5.0

  • added Debug\TraceableEventDispatcher (originally in HttpKernel)
  • changed Debug\TraceableEventDispatcherInterface to extend EventDispatcherInterface
  • added RegisterListenersPass (originally in HttpKernel)

2.1.0

  • added TraceableEventDispatcherInterface
  • added ContainerAwareEventDispatcher
  • added a reference to the EventDispatcher on the Event
  • added a reference to the Event name on the event
  • added fluid interface to the dispatch() method which now returns the Event object
  • added GenericEvent event class
  • added the possibility for subscribers to subscribe several times for the same event
  • added ImmutableEventDispatcher