12 11 / 2011
ExpressionEngine + Version Control
Version control has long been an integral part of any development team. One of the challenges I face when marrying the ExpressionEngine templates and version control with separate development, staging and production environments is keeping everything in sync. Let me begin by explaining a little about the development environment we use:
- Developers begin coding on their local machine using MAMP, committing frequently. The database lives on the staging server so that when the push to staging happens, no database merging/updating will be needed.
- Once the developer has a stable version of the site, he/she pushes their commits to the “develop” branch in a remote Git repository.
- The Git repository fires off a post-commit hook to a service that automatically deploys the code to the staging server where others can QC the work.
- After all the stakeholders are satisfied with the code as it lives in staging, the developer merges the code into the “production” branch and pushes to the repository.
- The Git repository fires off another post-commit hook that tells our deployment service to push the code to the production server.
- If needed, the developer will make any necessary database changes on the production server at this time.
- Finally, the developer and stakeholders QC the code in production to make sure all is well. If there are issues, our deployment service allows for a quick and easy rollback.
ExpressionEngine, in it’s current form, makes this workflow difficult to enforce. This is because anyone with the proper permissions can navigate to the template manager and make changes to a template that is in production—thereby bypassing source control and the entire workflow. Obviously, this is a huge problem because our production severs don’t commit changes back to the repository for obvious reasons. So when someone edits a template on the production server, nobody knows it happened and when we deploy a change to that template, it is very likely that the change will be lost or our working copy will become out of sync (depending on how we deploy the project).
You may be asking why go through all the trouble of setting up three separate environments and keeping your templates in source control? I’m not going to state the case for source control here but it really comes down to three things:
- When bad code is pushed to production, we need to know who wrote it and be able to quickly revert back to a previous version. EE’s template manager doesn’t give you the line-by-line blame that source control does. Also, the template editor promotes “change a line and save” type development that quickly makes it’s version history obsolete.
- You owe it to your clients to be diligent about the quality of work you push to production. Having separate environments prevents the developer from making non-tested changes to the code that break other parts of the production site.
- Source control is great for multiple-developer teams. There is nothing worse than two developers accidentally making changes to the same template, thus overwriting each other’s work. This is preventable and simply won’t happen with source control.
In an effort to preserve our workflow, I created an extension that disables the template editor in ExpressionEngine letting the developer know that the templates are under source control. This extension makes the templates and template groups in EE read-only. It doesn’t affect things like synchronization, PHP input/output parsing, and access control.
How to Use
This addon is just an extension that modifies some of the control panel’s code. There is no code to insert nor are there any settings. Just install and go.
Download
You can get the latest version of this extension from Github
15 5 / 2011
How To: Configure ExpressionEngine for Multiple Server Environments
One of the challenges ExpressionEngine developers who have separate development, staging, and production environments face is configuring EE to work in all three of those environments without having to modify code each time. Over the last few months, I’ve been looking for ways to make the EE configuration as dynamic as possible and here is what I’ve learned. The methods described here only pertain to ExpressionEngine 2.x.
Permalink 6 notes
17 4 / 2011
EE Addon: HTML/CSS/JavaScript Optimization with AutoMin
What is AutoMin?
AutoMin is an ExpressionEngine addon that automatically combines and compresses your template output, CSS and JavaScript code.
Features
- On-the-fly combination and minification of your CSS/JavaScript
- Intelligent caching mechanism detects when you’ve made a change to your tags or files
- Automatic compression of your HTML markup
- Handles CSS @import and @font-face with ease
- Support for EE’s global variables, path variables, and {stylesheet} variables
- Reports file size differences to the template debugger
- Basic support for EE 1.X
Permalink 6 notes
15 4 / 2011
Code: .htaccess for ExpressionEngine and CodeIgniter
Here is the .htaccess template I use for ExpressionEngine and CodeIgniter web sites. It’s well documented and has support for far-future expires headers, 301 redirects (vanity URLs), web fonts, gzip compression, index.php removal, etc. Thanks to the guys over at HTML5 boilerplate for some of the far-future and web fonts code.
Permalink 1 note
24 2 / 2011
Tutorial: LINQ to Entities in .NET Framework 4.0
Before I began working on a recent .Net Windows application, I was checking out some of the new data access methods in .Net Framework 4.0 and came across LINQ to Entities, which was available in .Net Framework 3.x, but was vastly improved in Framework 4.0. Today, I’m going to spend a few moments talking about the LINQ language and, more specifically, LINQ to Entities and what it means for object-oriented C# programmers.
Permalink 4 notes
18 1 / 2011
Think: An OOP's Approach to JavaScript
Sometimes it seems that there aren’t many hard-fast rules in programming. What works here, may not work there. What is best for this developer may not be best for another. One area where this is noticeably the case is the debate over coding standards and code-cleanliness. For me, this is always evolving as I discover new ways to make my code more maintainable, more readable, and just downright more beautiful. How well your code reads and looks is almost as important as how well it performs and is considered your first impression when another developer is tasked to maintain your code. Today, I will be suggesting a few techniques I use to write beautiful JavaScript code that is less prone to bugs and easier to maintain.
15 1 / 2011
Code: SVN Hooks for Staging Servers
I had to develop some SVN hooks to automate our push to staging at Paramore|Redd. I decided to take it a bit further and include PHP Syntax validation. Check out the scripts here and modify/use them as you need.
Permalink 1 note
04 11 / 2010
Free App: Easy Hosts File Editing with HostsFileHelper
Open source and available for both Mac and Windows, HostsFileHelper is a small application designed to take the hacker out of hosts file editing.
29 9 / 2010
How To: Server-Side Web Optimization
If you’re anything like me, you like snappy (you like to find what you’re looking for and find it quickly), and slow load times can greatly impact your workflow. Turns out we’re no different than most web users. In this article, I’ll give you a few reasons why you should worry about web site optimization and show you some simple technical things you can do to speed up your site’s load time and responsiveness.
Permalink 2 notes
