Manipulate XML data


I'm now evaluating to use Phalcon in my small project. Basically, I will retrieve XML feed frequently (i.e 5 secs) through HTTP GET. Then, this app will have insert xml data into DB (1MB ~ 5MB each XML). Any suggestion that how can I use phalcon to handle these data nicely.

edited Mar '14

If you need quite amount of time to process the data, you should consider to create a queue job using beanstalk. Phalcon implements beanstalk client since ver 1.1.0. Check

Below is the skeleton for the worker tasks for processing your data.

namespace BI\Console\Tasks;

class WorkerBase extends TaskBase
    protected $_tube = 'default';

    protected $_name = null;

    protected function process($data,&$error){
        //process your xml data here

    public function mainAction($arg)
        $q = $this->BeanstalkQueue; 
        while (true) {
            $job = @$q->reserve();
            $data = $job->getBody();    
            $processResult = $this->process($data, $error);


As @jeffreycahyono advice, this can be executed on CLI using a queue (such as beanstalkd) or by just simply running a cron job, note that Phalcon can't optimize/improve the I/O bound (network access, filesystem, etc) so retrieving this via web can take several seconds or even minutes making your page look slow.

Check this section ( out for more alternatives for queuing with PHP.