php-cli instancing

Works on linux debian and Win 7 - didn’t test anything else.

Sample config:




'phpInstancer' => array(

   'class' => 'PHPInstancer',

   'maxConcurrentInstances' => 25,

   'binaryPath' => '/usr/local/bin/php',

   'defaultScriptPath' => '/var/www/index.php',

),



I use it like this:




'phpInstancer' => array(

   'class' => 'PHPInstancer',

   'binaryPath' => APP_LOCAL ? 'Y:/xampplite/php/php.exe' : '/usr/local/bin/php',

   'defaultScriptPath' => APP_PATH . '/www/index.php',

),



Within a Yii console command, spawn unlimited instances of a another Yii console command, but $maxConcurrentInstances at a time:





while ($someCondition)

{


   if (Yii::app()->phpInstancer->canSpawnInstance())

   {

      Yii::app()->phpInstancer->spawnInstance(array('action', '--param=example'));

   }


   sleep(1);


}




Maybe useful to someone ;)

Added $debugOutput and $maxSystemLoad (not implemented for win). Attached example console command.

Can be handy. Are you going to create a documented extension?

Yes, probably better than posting any updates here. Will create the extension page in some days with documentation.

it 's interesting :lol: better that there is a wiki or extension for this two script files