HOWTO: Set up a CodeIgniter project in Subversion
After working with CodeIgniter for a few months (and WordPress for a few years), I’ve settled on a way to set up web projects that works well for development, deployment, and source control. Note that this style of layout only works on systems like Mac and Linux that have useful symlinks.1
First, the folder layout
some-domain.com/
app/
config/
controllers/
(etc)
public/
.htaccess -> ../site-extras/.htaccess
favicon.ico -> ../site-extras/favicon.ico
js/ -> ../site-extras/js
images/ -> ../site-extras/images
system/
application/ -> ../../app/
site-extras/
js/
images/
.htaccess
The layout favours a vhost setup, and splits your code and resources out of the CodeIgniter sources. Splitting your stuff from the CodeIgniter stuff lets you link your Subversion repository to theirs, so that you can keep it in sync with their development.
How it’s done
- Set up your source tree (not including the symlinks or CodeIgniter source) and add to your Subversion repo.
- Add a
svnlink to CodeIgniter’s repo (viasvn propedit svn:externals, withpublic http://dev.ellislab.com/svn/CodeIgniter/tags/v1.6.2/) and run asvn updateto grab the framework. See the Subversion docs for details. - Copy the CI
applicationfolder to the site root (asapp), remove the.svnfolders, symlink toapplication, and add it to your local svn repo. - Symlink the other site-extras to the
publicwebserver root, and configure your local machine (and public webserver) to point to this root for the domain’s virtual host setup. - Alternatively, you can modify the
$application_pathto point to../public/app/(I’m not sure which is better yet). See the CodeIgniter docs on apps for more details.
You now have a CodeIgnitor project ready for development. You can keep up-to-date with CodeIgniter updates, deploy easily, and get at your code without wading through extra levels of hierarchy.
- I don’t think that Windows is suited for PHP/MySQL/Apache development anyway, as it’s more work to configure, harder to get packages for, and lacks things like SSH, symlinks, and useful shells. But that’s me. ↩
