This howto will demonstrate how to start your cakephp project from scratch, taking advantage of subversions “externals definition”. The result will be a basic CakePHP directory structure with only the “/app” part under your svn control and the other directories linked to a specified revision of cakephp. Once setup, if you do a ’svn chekout’ of your project, you will get all the files at the right location, so no need to merge your ‘/app ‘ with the contents of a tarbal which you downloaded from the CakePHP website.
Let’s get started!
First, we create a temporary directory structure, just for the purpose of importing it:
$ mkdir temp $ mkdir temp/mynewproject $ mkdir temp/mynewproject $ svn import -m "New import" temp file:///home/me/subversion/ # remove the temporary directory structure $ rm -rf temp
Now, we checkout a working copy:
$ cd ~/src $ svn checkout file:///home/me/subversion/mynewproject
Ok, this just bought us an empty directory managed by subversion!! Let’s fill it with the use of some magic: Externals. We will create an externals definition for the directory. It will point to the current cakephp1.2 release, which is 5875 at time of writing.
$ cd mynewproject $ svn propedit svn:externals .
This will fire up your text editor with an empty text file. Type the following line, save and quit:
third-party/cake_1.2.0.5875 -r 5875 https://svn.cakephp.org/repo/trunk/cake/1.2.x.x/
Since this is an actual change to the current directory, we should commit it back to the repository:
$ svn commit -m "Added externals definition for CakePHP 1.2 rev. 5875"
By updating our working copy, the cakephp files will be downloaded to the in the property specified directory:
$ svn update
Wow, that’s nice, isn’t it! Oh… and btw, don’t forget to donate some change to the project!
Let’s go and make some symlinks and a copy of the ‘app’ directory:
$ ln -s third-party/cake_1.2.0.5875/.htaccess $ ln -s third-party/cake_1.2.0.5875/cake $ ln -s third-party/cake_1.2.0.5875/index.php # now create your own copy of the app directory $ cp -r third-party/cake_1.2.0.5875/app .
Since we don’t need the .svn directories from the cakephp svn checkout. We find and delete them:
$ find app -type d | grep \.svn | sort -r | xargs rm -rf
Finally, add the ‘/app’ directory and the simlinks to our own subversion repository
$ svn add .htaccess app cake index.php $ svn commit
That should be it!
Remember, when you want to upgrade your CakePHP version. It should be a matter of (a) editing the externals definition on the myproject directory. And (b) re-linking the symbolic links.
When gluing the cakephp directory structure by all those symlinks. The cake bake script might not correctly determine your app directory. Use the -app option to point the bake script to the correct app dir, like this:
./cake bake -app /var/www/cakephpproject/app