Subversion and multiple CakePHP apps

A few days ago i already wrote about how to set up a svn for cake.
In this second part i will cover the aspect of managing several apps.

The Problem

We have several apps, each with its own cake and vendor folder. If you need to update from 1.3.1 to 1.3.2 you would need to do that for each of your cake cores. Woudn’t it be nice if you changed one and all others would be updated automatically?

The Solution

Lets say, our apps have the following svn rep. urls:

Both have the same structure:

Both vendor and cake folder we now want to substitute with our shared folders

Sharing Cake Core and Vendors

We now put our cake core in svn under the following url:

and vendors:

In both apps, we need to edit the properties for the /trunk folder with the following schema:
svn:externals svn_url local_folder
svn:externals http://123.456.789.000/cake13 cake
svn:externals http://123.456.789.000/vendors vendors

If you update the cake13 or vendors svn, both apps will get the updated version.
Especially if you have more than 2 apps, this will be very helpful.

Extending to other folders

/app/plugins is a very common folder where you should use svn:externals instead of just copying your plugins to all apps. One change in any plugin version will affect the other ones.

/app/libs can have subfolders, too. So /app/libs/lib/… could contain a "library of libs" for all apps.
The same goes for /app/views/helpers, /app/controller/components, /app/models/behaviors/ etc

Your test cases should be in "lib" folders then, too.
Both inside those shared lib folders which are attached with svn:externals (in this case parent folder "components").

This might make sense in some cases. Most of the time, though, it’s better to create some kind of "tools" plugin where you can combine all your "library" files (common libs, helpers, components, behaviors, …).
And the test cases are easier managed, as well.

Final tips

You don’t necessarily need seperate svns for each external folder. They could all reside in one.
E.g with "common" svn:

svn:externals http://123.456.789.000/common/cake13 cake
svn:externals http://123.456.789.000/common/subfolder1/subfolder2/vendors vendors

Any svn subfolder is valid

NEW: Use github reps as external svns

Now you can include github reps in svn reps. Its as easy as including
in your folder properties.

This is especially useful, if you want to include one of the many cake plugins available at github without manually including it (changes would not be adopted).
Thats how i include my tools plugin in all my apps:
svn:externals tools
(in my /app/plugins folder properties)

Note: Currently it does not seem to work the other way around. Although planned to be available very soon, it didn’t work for me committing to such a git-svn rep externally included.
But most of the time, a simple checkout is more than enough. If you need to change the rep, you can do that with git itself and then update the svn rep (it will get the changes then anyway).

0.00 avg. rating (0% score) - 0 votes


  1. Hi Mark
    How do I install SVN on Windows 7 and use CakePHP ?
    who do i config SVN for use in the phpDesigner 7 IDE?

    plz help me!

  2. Honestly this is why I like to put /cake/ and /vendors into a separate directory altogether. If I want to change cake versions I simply edit index.php and test.php to reflect the new locations.

    my /usr/ dir looks kind of like this:

    unpack cake archive into separate folder:


    so for each "version" subdir, app, cake, and vendors folder would stay the same as the cake archived file

    I also put all my vendors in a separate directory so I can share no matter what version I am using

    What sucks about this approach is obviously diff’s between cake core, but I don’t really need to do that anyway since I can easily role back to a previous version in my index.php for my current app.

    Also I don’t hack the core like you =] so I don’t need the diffs

  3. Everybody’s own approach 🙂
    If I let other people help me, it is way easier to use externals because they can checkout all dependencies by themselves (automatically). only one url to "remember". everything’s contained right away – even without those packages being the same svn dir. they have permission to read "cake/vendors" but not to write/modify, though. They may only modify the app itself.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.