devbabuind / non-blocking-php
dev-master
2017-01-03 14:05 UTC
This package is not auto-updated.
Last update: 2024-05-11 18:07:25 UTC
README
Library for non blocking background jobs in PHP
Installation
Install composer in your project:
curl -s https://getcomposer.org/installer | php
Create a composer.json
file in your project root:
{ "require": { "devbabuind/non-blocking-php": "dev-master" } }
Install via composer:
php composer.phar install
Basic Usage
Hello World
Add this line to your application's index.php file:
require 'vendor/autoload.php';
Import the required classes into your namespace:
use DevBabuInd\NonBlockingPHP\Execute;
Instantiate a new Execute:
$execute = new Execute(array('autoMode' => true));
Add some parameters:
$query_params = array('foo'=>'bar'); $folder_protection = array('username' => 'test', 'password' => 'test'); /* sample parameters */ $params = array( 'url' => 'http://www.yourappdomain.com/job.php', 'command' => 'php /folderpathofyourapp/job.php', 'auth' => $folder_protection, 'args' => $query_params );
Now run the job:
$result = $execute->run($params);
You can get the output:
if ($result) { echo "Yay! Background call initiated"; } else { print_r($execute->getError()); }