Ever since CodeIgniter moved over to GitHub I’ve been interested in figuring out a way to use the EllisLab repository code inline with our specific project code to simplify updates but haven’t found a great way to go about it.
Fairly recently I came across CodeIgniter Starter which is a step in the right directoin: A GitHub repo that has some configuration and project setup in place. I didn’t love that it comes with certain Sparks pre-installed and at Bold we run our system files outside of the webroot. Still left me with a decent amount of configuration to get up and running.
I use Sublime Text 2 for coding (you probably should be using it too) and recently there was a great Package built by NetTuts called NetTuts+ Fetch. It simplifies the retrieval of remote files and packages by downloading them from a preset source and “injecting” them into a project. It got my juices flowing again about automating CodeIgniter project setups.
Enter Bash scripting. I’ve always loved Bash scripts and realized that this was the perfect use case. Let’s automate all of the steps and configuration that happens on every new CI project with a short command line operation.
As I mentioned, at Bold we run CI system files outside of the webroot. This script retrieves the latest CI version, automates the clean up of the folder structure, installs placeholder asset files, and optionally sets up the Sparks installer (no actual Sparks are installed), adds the project to a local Git repo, pushes the initial commit to a remote Repo, and installs Git Flow. Lots of stuff going on there, but now deploying a new CI project takes about 10-15 seconds from start to finish. Pretty great!
Check out the code and full docs on GitHub at: https://github.com/gstjohn/codeigniter-startup-script