EllisLab is blessed with two of the greatest communities that can be found anywhere on the internet in ExpressionEngine and more recently CodeIgniter. Despite being a relative newcomer to the scene, the people attracted to CodeIgniter are among the smartest, most talented and down-to-earth developers around today. From time to time we want to highlight some of these talented people, and we’ve asked them to lend their voice to ours. Have your voice. I hope you enjoy what they have to say as much as I did.
This week, our Community Voice author is Bruce Alderson, known on the forums as madmaxx, who has written a wonderful guide on how he uses subversion with CodeIgniter. Bruce is an elder web monkey and systems programmer. He totally digs the craft of building software, making cool stuff, and causing people to laugh so hard liquids are forced from their nose. He’s currently the Chief Monkey at Discovery Software and author of the not-at-all famous robotpony.ca. (Go read the one about shaving your yak)
While I prefer to stick with the default CI directory structure, I do find it helps to set svn:ignore on cache/* and logs/*.php, as well as on config.php and database.php. Then I’ll add config.php.default and database.php.default to the repository, so they just have to be renamed and modified for the dev/test/prod server environment.
But I do feel this is kind of a work around for something that could be handled by CI itself.
I would really appreciate it if:
CodeIgniter’s code and the application code would be separated by CI’s design, rather than having to rely on symlinks. I mean separation at the root directory, like proposed above.
the server specific configuration (database username and password, application URL, etc.) was also separated into a directory in the root. Now I have to go into a directory and change *part of* a several configuration files.
All I ended up doing is kept to the same structure as CI aside from creating a separate “web” folder that I set the web root too, thus preventing any access to system folder from a url. I then just throw the whole thing in subversion with a config.default.php and database.default.php. When there are upgrades to CI I just unpack the new version, copy everything over, make sure everything works and commit it all to subversion. It makes the repository larger since I’m versioning the CI source instead of just an SVN:EXTERNALS link, but makes things easy to deploy.
Another thing to keep in mind is at least apache servers by default usually have a deny rule set for “.*” files. Meaning any file that begins with a ., like “.svn” won’t be served to web clients. So it’s completely fine to leave the .svn folders in there. Of course I would try to access the .svn folders from a web browser to make sure, but more than likely it’s already being blocked.
A comment on the article: I do not like the external reference to the codeigniter repository. While usually the code will not break when updating CI sometimes this might happen. Therefore I prefer to pick the latest version, code the project and just keep that version. When there are updates/bugfixes I prefer to check the changes myself to avoid code breaking.
I really like the idea of tracking CI out of SVN, so I’ll incorporate that. For the application, I’ve tried a similar, yet different approach.
I wanted to separate my application code completely from the CI source tree. I also wanted to be able to use a single CI source tree for all of my applications. For the time being, everything is under a user’s home directory. Here’s what it looks like:
I suppose the big difference is that the CI tree isn’t in the public web space, my application is. The part that I like is that I can have multiple applications, either in parallel with each other, or nested in sub-directories. All point back at $home_dir.”/lib/CodeIgniter/system” which leaves me with a single CI tree to keep updated. It wouldn’t be hard to reference multiple versions either, if something unique broke or changed with a CI update.
I don’t think my method allows “one-click” SVN updates, since the CI tree and the app tree are intentionally separated (to allow for multiple apps). I’ll look for a way to have my cake and eat it too.
Yeap it should be a bit more explained on some informations. I set this using TortoiseSVN. So I look at this :
the point 3, 4 & 5 need to be more detailed.
how can I let the external svn ignore the application forlder?
I am also curious about the application folder that is in the CI system folder.
I have to remove that from the system folder (put in place by the svn:externals) in order to create a symlink to the app folder.
How do I do that without a) having svn keep trying to update the system/application folder as it is updated in the CodeIgniter repository (I want to track trunk with this)
or b) potentially removing it from the CodeIgniter repo? I certainly don’t have permissions for that, but still, it seems odd.
OK, it’s a little extreme to think that I could remove the application folder from the CI repo. But when I removed the local copy of the folder (with a normal rm -rf application) and add the symlink, I get a message that the folder is locked when I try to update.
before doing my first commit, then I make duplicates of the files and remove the “_template” part and never commit the new config.php / database.php files. the reason is because obviously from server to server your config and db settings are going to be different. whilst you could faff with svn:ignore to do something similar, I find it is helpful to have the original base file committed as a template.