nphp
v1.0.5
Published
NPHP is a library, that build for npm, the node package manager, to be used for php scripts. If you are interseted in `npm` over `composer` for include/distribute packages, you can use `nphp`
Downloads
7
Readme
#NPHP: NPM packaging for PHP scripts
NPHP is a library, that build for npm, the node package manager, to be used for php scripts.
If you are interseted in npm
over composer
for include/distribute packages, you can use nphp
Simple project with 1 npm php dependency
Step 1: Create an npm project
mkdir nphp-dependency
cd nphp-dependency
npm init
Step 2: Edit dependecy package
NPHP forces to developer mention in package.json
this is a php package, by setting nphp: true
in package.json.
Also, You have to defined main field to a php file, mostly by default entrypoint.php
Step 3: Add entrypoint.php
Add a entrypoint.php file near package.json
file, and place this content for sample:
function DepTestFunction() {
echo "Dep test...";
}
Step 4: publish or put in git
Now you have a simple php node module, you can publish it to npm, if you want to use it in another package.
We have published nphp-dependecy
in npm and also available in git:
git clone https://github.com/torabian/nphp-dependecy
#Including dependencies
After installing nphp
, you need to include this script
include './node_modules/nphp/nphp.php';
use nphp\PackageJSON as pkgvendor;
pkgvendor::ImportDependecies();
DepTestFunction();
###Setting working directory In some cases, your include entrypoint is inaccessible, so there is an option to set the working directory. Moslty in WordPress cases
pkgvendor::CWD('./wp-content/themes/twentyfifthen/');
# Before calling Import Dependencies, we sat the cwd
# pkgvendor::ImportDependecies();