Skip to content

Commit

Permalink
Merge branch 'master' of github.com:puritys/nodejs-phplike
Browse files Browse the repository at this point in the history
  • Loading branch information
puritys committed Jul 5, 2016
2 parents 8065dde + bb59a14 commit f8dd326
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ Node.js - phplike
Chinese Readme: https://github.com/puritys/nodejs-phplike/wiki/%E4%B8%AD%E6%96%87%E7%89%88-Readme


This project's purpose is to implement some useful PHP functions for Node.js or Io.js.
This project's purpose is to provider some PHP synchronous functions for the web development on Node.js.

Node.js is a event-driven language and it's methods usually use asynchronous IO. Asynchronous IO is not a bad way for any web system. But sometimes, we want to make code be readable and easier to be maintainable. The phplike support many synchronous functions for Node.js.
Node.js is a event-driven language and it has many asynchronous I/O methods. Asynchronous functions is not a bad way for a web system, it help us to develop a non-blocking I/O program. But sometimes, we want to make code readable and easier to be maintained that asynchronous functions don't have them.

In order to reduce the number of callback functions on Node.js scripts and improve the readability. I create the library phplike which supports many synchronous functions for Node.js such as "exec", "curl", "fsockopen" that can be executed without complicated callback functions. In additional, phplike provides the function cUrl which has the same operations with PHP's function called curl. It will let you make a HTTP request synchronously.

Phplike support synchronous functions such as "exec", "curl", "fsockopen" executing without callback function. It can reduce the number of callback functions, also will make the code easier to maintain, and phplike provide the function cUrl which is just like php's function called curl. It will let you make a HTTP request synchronously.

* npm: https://npmjs.org/package/phplike
* All version: https://registry.npmjs.org/phplike
Expand All @@ -20,11 +21,11 @@ Travis CI status: [![Unit testing](https://travis-ci.org/puritys/nodejs-phplike.
<img src="https://camo.githubusercontent.com/fe2d9e9063dabaf5951ef8f3835bbbc16cec52e3/68747470733a2f2f706f7365722e707567782e6f72672f7a6f72646975732f6c696768746e63616e64792f6c6963656e73652e737667" alt="license">


##Install phplike
## Install phplike

* sudo npm install -g phplike

If your computer is not a common OS, then you will need to install node-gyp first. The installation of phplike library will compile the C/C++ code with node-gyp. Usually, NPM will automatically install node-gyp when you try to install phplike. Or you can install node-gyp by yourself.
If your computer is not a normal OS, and it doesn't have the header files of Curl, You will need to install node-gyp first. The installation of phplike library will compile the C/C++ code with node-gyp. Usually, NPM will automatically install node-gyp when you try to install phplike. Or you can install node-gyp by yourself.

* sudo npm install -g node-gyp

Expand All @@ -36,12 +37,12 @@ If your computer is not a common OS, then you will need to install node-gyp firs

How many OS does phplike support?
---------------------------
* Linux : Every version of phplike support linux system.
* Linux : Every version of phplike support linux systems.
* Mac : Supported from phplike@2.0.5 to latest
* Windows: Supported only in phplike@2.1.0 、 phplike@2.2.8 , phplike@2.4.4 , I had ever test phplike on windows 8 and windows xp.
* Raspberry PI(Pidora OS with ARM CPU): phplike@2.2.2 ~
* Windows: Only the following version are supported: phplike@2.1.0 、 phplike@2.2.8 , phplike@2.4.4 . I have tested features of phplike on windows 8 and windows xp.
* Raspberry PI (Pidora OS with ARM CPU): phplike@2.2.2 ~ Latest

| OS | Suggested phplie Version |
| OS | Suggested phplike Version |
|----------|:-------------:|
| Linux | Latest |
| Mac | 2.0.5 ~ latest |
Expand All @@ -54,7 +55,7 @@ Dependency
-----------
* Phplike have been already tested in Node.js version from 0.10.x to 0.12.x and io.js 1.0.0 to 2.1.0. Here is the test report : https://travis-ci.org/puritys/nodejs-phplike
* libcurl (libcurl-7.19) : Linux system already have this built-in package. Please install libcurl-devel : sudo yum install libcurl-devel
* python 2.4 ~ : phplike use node-gyp to compile C/C++ codes. It needs python which's version must be bigger than 2.7.8, you can download the python from here https://www.python.org/downloads/.
* python 2.4 ~ : phplike use node-gyp to compile C/C++ codes. It needs python with the version must be bigger than 2.7.8 , you can download python from here https://www.python.org/downloads/.

After the new version of phplike 2.2.0, I committed all binary files which already compiled in Windows, Mac and Linux, you can just install the phplike without compiling C/C++ now.

Expand Down Expand Up @@ -161,7 +162,7 @@ Completed PHP Method
Execute phplike in global mode sample
-------------------------------

If you require the index.js of phplike, then you can use the phplike's functions in global object. It means that you don't need the prefix to call the phplike's function. To execute functions like a real php coding.
You can directly use the phplike functions. The functions of phplike are defined at the global object when you require the index.js. It means that you don't need the prefix before calling the phplike's function. The Node.js coding will be more like PHP's. The only one disadvantage is that defining a function at global object is easier to meet the conflict problem.

exec(command, printInScreen = true);

Expand All @@ -174,9 +175,10 @@ exec(command, printInScreen = true);
</pre>

Execute phplike in module mode sample (phplike 2.0)
------------------------------
----------------------------------------------

You can require module.js of phplike, then you will need prefix to call phplike function, the module mode will not change the method of global object and can separate the Phplike's functions from native Node.js functions .

You can require the module.js of phplike, it will return the Phplike object. This object includes many functions of PHP for you to use at anytime. The module mode will not change the methos of global object so it won't be conflict with other Node.js native functions.

```
var php = require("phplike/module.js");
Expand Down Expand Up @@ -206,6 +208,7 @@ Example code for php curl

Example code for php post (Using module mode)
------------------------------

```
var php = require("phplike/module.js");
var url = "http://localhost:8080/";
Expand Down

0 comments on commit f8dd326

Please sign in to comment.