Monday, January 26, 2009

Changing CakePHP's tmp directory so it won't be included on SVN

Update: this solution is quite dirty, and I don't recommend it now. Check out my new post on using SVN's ignore property to ignore CakePHP's tmp directory.

If you're putting your CakePHP app on version control (SVN), you'll notice that the /tmp directory is inside /app. You might want to not include /tmp on your repository as it's just a location for caches, logs, session, and other temporary stuff which is not part of your application code. Here's how to change the tmp directory of CakePHP:

1. Copy /app/tmp to /tmp (copy it outside of the app directory)
2. Add this code on /app/webroot/index.php after CAKE_CORE_INCLUDE_PATH is defined (line ~60). This will change the tmp directory from /app/tmp to /tmp.
# define a different TMP dir outside of app
define('TMP', ROOT.DS.'tmp'.DS);
3. Configure the file cache path on /app/config/core.php (line ~226):
Cache::config('default', array('engine' => 'File', 'path' => ROOT.DS.'tmp'.DS) );
(This step is necessary for BAKE to work properly if you are using the default file cache)
4. To check if it's working fine, try renaming /app/tmp to /app/xtmp and see if your app still works properly (then you can already delete that directory). If not, make sure the new tmp directory is the same as the original structure (cache, logs, sessions, tests)

5 comments:

  1. simple but useful. great tip. good to know a fellow baker from PH. :)

    keep it up.

    ReplyDelete
  2. thanks ;) I'm just starting out with cakephp. btw I've been a fan of pinoywebstartup since it came out (last year?).. why no updates recently?

    ReplyDelete
  3. i'm glad you have interest on pinoywebstartup... about that, Marie (who is the only writer & editor) went on a vacation but she just got back here in PH and will soon put updates on it. :)

    catch you on IM

    ReplyDelete
  4. Nice tutorial....thanks for this post.....
    Please visit this link for learn more script.
    http://amitmondal.wordpress.com/

    ReplyDelete
  5. can the path for caching be changed in the app controller (according to some condition)?

    I'd like to use a different path for view cache according to the current language (locale).

    thanks in advance

    ReplyDelete