RSS
 
24. May. 2011

Cakephp Console on Linux systems

24 May

You could hard-wire the Cake path into the environment. With multiple cake core versions on a single system, sometimes it is better not to do that, though. So I just follow the following guidelines:

  • Only add the PHP path to the system environment path (not the cake one!)
  • Always navigate to your app folder.
  • Call your shells from there, either with Console/cake (if you have an app Console folder with cake file) or ../lib/Cake/Console/cake (core cake file).

Cronjobs

The documentation in the cookbook is pretty well written.

Here with a little bit more detailed explanation:

# m h dom mon dow command
*/5 *   *   *   * cd /full/path/to/app && Console/cake myshell myparam

The tool Crontab is used here. This config file contains an example with a cronjob that is executed every 5 minutes. Basically, you just tell the script to navigate into your app folder and call your shell as you normally would as real user (always from inside your app folder).

If you don’t have an app cake file (I don’t for some older projects), you can also use the core cake file just as fine:

# m h dom mon dow command
*/5 *   *   *   * cd /full/path/to/app && ../lib/Console/cake myshell myparam

You can edit the crontab for the www-data user, for example, using

crontab -e -u www-data

Using the user “www-data” (or a user that is affiliated with it) is advised to prevent running into issues with file access when creating or modifying files. It is also a security issue using a user with more or different rights than he should have or needs.

CakePHP 2.x and windows

See the updated windows post for the correct path here. Also note the way more comfortable quick-links if you need to use 1.x and 2.x parallel.

Cakephp Console on Linux systems
0 votes, 0.00 avg. rating (0% score)
 
1 Comment

Posted by Mark in CakePHP

 

Tags: , , , ,

Leave a Reply

Tip:
If you need to post a piece of code use {code type=php}...{/code}.
Allowed types are "php", "mysql", "html", "js", "css".

Please do not escape your post (leave all ", <, > and & as they are!). If you have encoded characters and need to reverse ("decode") it, you can do that here!
 

 
  1. stefano

    May 24, 2011 at 16:56

    Good tip :)