Introduction to Zend Framework

 Learning Zend Framework


 Zend Framework Reference

  •  Zend_Gdata
  •  Zend_Http
  •  Zend_InfoCard
  •  Zend_Json
  •  Zend_Layout
  •  Zend_Ldap
  •  Zend_Loader
  •  Zend_Locale
  •  Zend_Log
  •  Zend_Mail
  •  Zend_Markup
  •  Zend_Measure
  •  Zend_Memory
  •  Zend_Mime
  •  Zend_Navigation
  •  Zend_Oauth
  •  Zend_OpenId
  •  Zend_Paginator
  •  Zend_Pdf
  •  Zend_ProgressBar
  •  Zend_Queue
  •  Zend_Reflection
  •  Zend_Registry
  •  Zend_Rest

  •  Zend_Search_Lucene
  •  Zend_Serializer
  •  Zend_Server
  •  Zend_Service
  •  Zend_Session
  •  Zend_Soap
  •  Zend_Tag
  •  Zend_Test
  •  Zend_Text
  •  Zend_TimeSync
  •  Zend_Tool
  •  Zend_Tool_Framework
  •  Zend_Tool_Project
  •  Zend_Translate
  •  Zend_Uri
  •  Zend_Validate
  •  Zend_Version
  •  Zend_View
  •  Zend_Wildfire
  •  Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Update 2010-10-10 - Revision 23064 - Version ZF 1.10.x

    Chapter 1. ZendX_Console_Process_Unix

    1.1. ZendX_Console_Process_Unix

    1.1.1. Introduction

    ZendX_Console_Process_Unix allows developers to spawn an object as a new process, and so do multiple tasks in parallel on console environments. Through its specific nature, it is only working on *nix based systems like Linux, Solaris, Mac/OSx and such. Additionally, the shmop_*, pcntl_* and posix_* modules are required for this component to run. If one of the requirements is not met, it will throw an exception after instantiating the component.

    1.1.2. Basic usage of ZendX_Console_Process_Unix

    ZendX_Console_Process_Unix is an abstract class, which requires the user to extend it. It has a single abstract method called _run() which has to be implemented to create a working process. It also comes with multiple methods for checking the alive status and share variables between the parent and the child process.

    The _run() method and every method which is called by it is executed by the child process. Every other method which is called directly by the parent is executed by the parent process.

    setVariable() and getVariable() can be used from both the parent- and the child process to share variables. To observe the alive status, the child process should call _setAlive() in a frequent interval, so that the parent process can check the last alive time via getLastAlive(). To get the PID of the child process, the parent can call getPid().

    Example 1.1. Basic example for processing

    This example illustrates a basic child process

    class MyProcess extends ZendX_Console_Process_Unix
        protected function 
            for (
    $i 0$i 10$i++) {
    // Doing something really important which can't wait: sleeping

    // This part should last about 10 seconds, not 20.
    $process1 = new MyProcess();

    $process2 = new MyProcess();

    while (
    $process1->isRunning() || $process2->isRunning()) {

    'All processes completed';

    In this example a process is forked twice and executed. As every process runs 10 seconds, the parent process will be finished after 10 seconds (and not 20).

    digg delicious meneame google twitter technorati facebook