PHP code example of nodejs-php-fallback / nodejs-php-fallback
1. Go to this page and download the library: Download nodejs-php-fallback/nodejs-php-fallback library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nodejs-php-fallback / nodejs-php-fallback example snippets
use NodejsPhpFallback\NodejsPhpFallback;
use Stylus\Stylus;
function getCssFromStylusFile($stylusFile)
{
$node = new NodejsPhpFallback();
$fallback = function () use ($stylusFile) {
$stylus = new Stylus();
return $stylus->fromFile($stylusFile)->toString();
};
return $node->execModuleScript('stylus', 'bin/stylus', '--print ' . escapeshellarg($stylusFile), $fallback);
}
$css = getCssFromStylusFile('path/to/my-stylus-file.styl');
json
...
"ejs-php-fallback/nodejs-php-fallback": "*",
"kylekatarnls/stylus": "*"
},
"extra": {
"npm": {
"stylus": "^0.54"
}
},
"scripts": {
"post-install-cmd": [
"NodejsPhpFallback\\NodejsPhpFallback::install"
],
"post-update-cmd": [
"NodejsPhpFallback\\NodejsPhpFallback::install"
]
},
...