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.13k
    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:

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

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

    1. App::uses('Shell', 'Console');
    2.  
    3. class ExampleShell extends AppShell {
    4.  
    5.  
    6.  
    7. /**
    8. * Default (no argument) method, inform the console of available commands
    9. *
    10. * @return void
    11. */
    12. public function main() {
    13. $this->_renderHeader();
    14. $this->out(' Usage:', 1);
    15. $this->out(" * <info>run</info> - Processes the tasks immediately.", 1);
    16.  
    17. }
    18.  
    19. /**
    20. *
    21. * @return void
    22. */
    23. public function run() {
    24. //your code here
    25. }
    26.  
    27.  
    28. }
    29.  
    30. Command: app/Console/cake Custom.Example run

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: