# nphp

> 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`

Latest version **1.0.5** (published 2016-10-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install nphp
pnpm add nphp
yarn add nphp
bun add nphp
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2016-10-05 |
| First published | 2016-09-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ali Torabi |
| Maintainers | connexion |

## Links

- npm: https://www.npmjs.com/package/nphp
- Repository: https://github.com/torabian/nphp
- Homepage: https://github.com/torabian/nphp#readme
- Issues: https://github.com/torabian/nphp/issues
- npm.io page: https://npm.io/package/nphp

## Recent versions

- 1.0.5 (latest) — 2016-10-05
- 1.0.4 — 2016-09-03
- 1.0.3 — 2016-09-03
- 1.0.1 — 2016-09-02

## 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:

```php
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

```php
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();
```

---
_Source: https://npm.io/package/nphp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
