Download the PHP package iankuca/node without Composer
On this page you can find all versions of the php package iankuca/node. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package node
Short Description An asynchronous PHP framework with and event loop (node.js-like)
License Do What The Fuck You Want To Public License
Homepage https://github.com/jankuca/node.php
Informations about the package node
node.php
An asynchronous PHP framework with an event loop (node.js-like)
Installation
The preferred way is to use composer.
{
"require": { "iankuca/node": "*" }
}
Or just use this repository directly.
Usage
$ php -f main.php yourfile.php
Examples
Timeouts
This prints AB
and adds C
after 2 seconds. Then it exits.
HTTP Server
This creates an HTTP server listening on the port 8080. It writes Hello world!
to each response. It does not exit by itself.
HTTP Request
This makes an HTTP GET
request to http://ifoconfig.me/ip
and asynchronously calls the provided callback function when a response object is ready. If waits for response body. Then it exits.
The standard output would be…
status: 200
Array
(...)
XX.XX.XX.XX
Directory Listing
Spawns a child ls -a /tmp
process and asynchronously calls the provided callback function when done. Then it exits.
Logging
Since the standard output of the process does not go to the browser, eventual exceptions and warnings are visible in the terminal window. The native exception stringifier is pretty horrible which is why node.php includes its own error formatter. Exceptions are now a lot nicer:
Another addition is the console_log()
function which is basically sprintf
that outputs to the standard output with an added end-of-line (\n
) character.
console_log('%d + %d = %s', 1, 2, 'awesome');
// stdout: 1 + 2 = awesome