Skip to content
/ dotphp Public

🔀 Require PHP files from Node.js with Uniter

Notifications You must be signed in to change notification settings

uniter/dotphp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

🔀 Require PHP files from Node.js with Uniter

Resources

Stars

Watchers

Forks

Packages

No packages published