Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Creating background Tasks with Appshell and CakePHP

    • 0
    • 1
    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 1.11k
    Comment on it

    Hello Friends,

    Sometime we need to run some background tasks using cakephp without user interaction or delayed response to user from server.

    For this we can use CAKEPHP AppShell utility.

    Syntax:

    /path/to/cake/console/cake -app /path/to/app/ <shell> <task>
    

    Example: Create the Shell Skeleton File: app/Plugin/Custom/Console/Command/ExampleShell.php

    App::uses('Shell', 'Console');    
    
    class ExampleShell extends AppShell {
    
    
    
        /**
         * Default (no argument) method, inform the console of available commands
         *
         * @return void
         */
        public function main() {
            $this->_renderHeader();
            $this->out('   Usage:', 1);
            $this->out("     * <info>run</info>          - Processes the tasks immediately.", 1);
    
        }
    
        /**  
         *
         * @return void
         */
        public function run() {
            //your code here
        }
    
    
    }
    
    Command: app/Console/cake Custom.Example run
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: