PHP code example of jrsaunders / quickasync

1. Go to this page and download the library: Download jrsaunders/quickasync library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jrsaunders / quickasync example snippets



use QuickAsync\Setup;

Setup::setBasePath( '/var/www/vhost/some/dir/async' );




$multiProcess = new \QuickAsync\MultiProcess(BASEPATH . '../cron.php /async/run/%%file%%');
$sleepBetweenCollections = 1;
$killMultiProcessCollectionsAfterSeconds = 60;
$multiProcess->process($sleepBetweenCollections, $killMultiProcessCollectionsAfterSeconds);




class Async extends MyApp {
	public function run( $asyncFile = null ) {
		if ( isset( $asyncFile ) ) {
			$queueItem = new \QuickAsync\QueueItem( $asyncFile );
			$asyncData = $queueItem->getObject();
		    $queueItem->run( $this );
		}
	}


}



use QuickAsync\Item;

class CoolClass extends MyApp(){

  public function somethingCool($name,$carName){
      
      //save this car to my name or something like that do some complicated processing.....
      return $importantData;
  }
  
  public function triggerAsyncProcess(){
      $asyncItem = new Item($this,'CoolClass','somethingCool',['John','Lamborghini'],__FILE__);
      asyncItem->queue();
  
  }


}