Using Twig with its built in dynamic templating system to populate and control your website “views”  — any files that process and deliver output to a browser, is a useful option to consider, especially if you are using the Symfony 2+ Framework since they go hand-in-hand.  That said, you can just take the Twig bundle from Twig’s official website and use it for any type of website regardless of the framework or if you aren’t even using a framework.  You can even use Twig with WordPress with a little finagling, in case you use a lot of external custom forms that you still have to embed into a CMS.

Some templating engines just use placeholders and basic wildcard replacement of a string to replace some placeholder text with dynamic values.  Twig goes much further and incorporates the basic PHP commands a template needs and basic logic you would need your view to perform –such as basic if/then logic and foreach statements to easily loop through values like so:

{% for user in users %}
* {{ user.name }}
{% else %}
No users were found.
{% endfor %}

Twig, like other Symfony bundles, can work as a standalone library.  Like other libraries that come with a class object using these tools can help streamline and perform certain tasks in a more automated and predictable fashion.  After all, we don’t keep creating our own portal to access our database, right?  No, we use MySQL Workbench or PHPMyAdmin or some other “dashboard” solution already out there.  These libraries are nothing different.

When you use a library, this means you can download these bundles and use them as a collection of classes that all work together to help you code more efficiently because you don’t have to keep reinventing the wheel for those tasks that you repeatedly perform as a coder, so you can focus your time and energy developing the real custom business logic instead of doing “busy work” kind of coding. Who wants to keep creating a user authentication admin when a proven one already exists?

Twig and Assetic

Another great bundle to consider is “Assetic” which goes really well with Twig to help optimize your site by combining assets, like multiple CSS files into a single minified style sheet file.  Assetic and Twig work seamlessly with each other.

Here is a great article that goes in depth with how these two processes work together:  http://richardmiller.co.uk/2011/05/13/symfony2-using-assetic-from-twig/

Assetic can even help you optimize and reformat your website images then automatically save all your optimizations to files in preparation to going live with NO processing on the live site.  It’s a way to set up your assets in dev then save it all for caching for your production site.  It’s an interesting tool and workflow that makes sense for web developers who are going to encounter a lot of images on the site, especially if it’s a publishing or multimedia site.

The best way to learn Twig is to use it.  Twig template files are based on extending a basic view of your site’s standard page then inheriting and overriding parts of the pages you need to alter by creating new content in “blocks”.  It’s pretty easy and intuitive to learn.  Twig really isn’t a language as much as it is a syntax with rules applied to perform different actions.  There are only 3 types of tags in Twig, each are enveloped with double curly brackets:  “{{ # This is a comment }}”.

Another benefit of using Twig is that it is clean for non-coders to read and follow, since most graphic designers are used to some sort of placeholder logic from using InDesign or some sort of email campaign website where something like “[first_name] [last_name]” is used, they should get the hang of Twig.   And you, as a web developer, can rest assured knowing that anything a non-coder in your isolated Twig view does won’t come back to haunt your code and business logic later.

By making sure there is no actual PHP system controls, environment variables, global variables, and other pertinent cogs that could be affected, your templates isolate the design of your views from any values and business logic from the rest of your website.  Imagine if you declared some important variable inside your homemade PHP view (which should never be done anyway so chances are you inherited that mess, right?) and that important variable was deleted, or worse: redefined.  What crazy things could happen!  This is why your views need to always be separate from your business logic, which should be housed safely inside controllers far from the prying eyes and potential mischief of curious “non-coder” designers.


Since 2004, Google has released search data measured and compared over time.  Useful to identify trends, compare interests, all while helping you spot the best and most effective keywords for your website and business.  As most marketers understand, quantifying data like number of unique visitors to your website is very important, but to add that dimension of time to these numbers makes this information much more useful and valuable.

Relevant business data will help your bottom line immensely

This is the kind of research not limited to your company’s marketing, you can apply results from your keyword research to help you make other informed decisions.  A few times in the past 3 months as a web developer, I was involved with helping companies make a decision about which PHP framework (Zend, Symfony, Yii, etc) and CMS (WordPress, Drupal or Joomla) would most likely be easiest to find development talent in the future.  Deciding on the best tools with the most future compatibility by researching the Google Trends of these tools can help make sure you invest your web development team’s time and money developing in the right content management system (CMS – currently WordPress) and the right PHP Framework (if applicable — Zend and Symfony were highest ranked, though “Code Ignitor” was strong, but its company, Ellis Lab has been shopping basically for a buyer for Code Ignitor these past 2 years).

Other useful research tools

There are other useful tools out there, such as Google Webmaster Tools, Bing Keywords Research, Alexa, Web Trends, and now Adobe Analytics, among many other sites that aggregate web traffic data, that can help you isolate your website and the affect of web searches on your own web assets.  This will help you predict how many potential visitors to your website will stumble onto a page based on the text they type in to a search.

A current Google Trends example

First, let me preface this quick overview by saying I hope the best for the actor Tracy Morgan, who I just found out on Google Trends was severely injured in a car accident.  Our hope and prayers go to him and his family.  If you haven’t ever used this tool, go over to Google Trends and look around.  If you have Google or a YouTube account, you will see a familiar layout and interface — the clean “Google” layouts.  Here’s a screenshot of today’s Google Trends:

google-trends-screenshot-2014-06-07

Here you see the movie “The Fault In Our Stars” along with “Orange is the New Black” and some hope for America — there is still some interest in the search term “D Day” along with Miley Cyrus — that’s “D Day” without the “dash” between the “D”s.  In Google Trends, clicking in the search text box will reveal more trending suggestions, of course “Barrack Obama” and “LeBron James” show up.  Digression:  Hard to tell with all the boxy layouts these days if Google inspired Windows Metro interface or the other way around, but I guess boxy is the best for UX if you are accommodating touchscreens.

Of course, this is just one source of data you need to consider in making decisions.  The more important the decision and the higher the potential investment or loss you may incur making a quick, short-sighted “gut instinct” decision, the more research you should compile to make sure you get the clearest picture to help you make those important decisions that you and your company will have to live with well into the future.  It also helps raise concerns — and awareness to alternatives you may never have considered.

Summary about Trends limitations

Trends research also serves as a warning when you are bucking conventional wisdom.  What you discover will hopefully raise more questions to help round out your research and make you pursue more details about topics that will help you make a decision.  Unless you are very experienced and a true expert in the realm of expertise you are researching, when it comes to trying to make the best decisions for your business and the future of your company’s operations, better delay a decision until you have all the facts then forge ahead because a decision needs to be made.  Being bold sometimes means admitting you need more research, which requires more time, but the old adage “an ounce of prevention” doesn’t even apply here.  This is a whole pound of prevention that can save you and your company a lot of time, trouble and costs turning the ship in a different direction or course because you didn’t have all the relevant facts and data the first time.


I first learned about Doctrine, the PHP-based database project, in 2008.  At the time I didn’t understand why would you need an intermediary layer between your applications and your database, which is what Doctrine is — a “DBAL” — Database Abstraction Layer.  Why can’t everything just talk to each other directly?  Years went by and though I learned some things about Doctrine and Object Relational Mappers (ORM)s I didn’t have a solid grasp of how to use it in a practical, real-world application.  No company thought it was necessary, they preferred to keep all their databases and direct querying because that’s all they knew.

Why make something that’s already complicated even more complicated?  At least that was the questions I heard.  In actuality, wouldn’t it be easier to visit a foreign country with someone who could translate, speak the language, and knew their way around?  A pretty good analogy — that’s what Doctrine does for databases.

For most companies and applications I developed web solutions for, there really was no immediate need for this kind of solution.  They weren’t ready to scale this way — at least with their systems and data.  Let the web application talk directly to the database, we’ll worry about growth later.

Just getting a company to consider using a database at the time and dedicating time to not only design it, but maintaining it, was quite a hurdle!

It takes time, thought, and real work to set up a database properly and to make sure all the systems in the company that pour information into it and feed information from it are all working optimally, so when you start talking to non-technical people about the importance of their database and how it affects everything throughout their entire system, it’s hard to calculate the costs and the ROI from investing in such improvements.  Remember it affects every person who accesses this company’s computer system or website, so it wouldn’t be difficult to help realize the opportunity costs incurred by not acting!

Think of using ORMs for your company like “Database Insurance”

It’s not that it’s very complicated. Your company outgrows its small rented office and needs to find a real building.  Without having an ORM to protect your company’s database, it’s like finding out you can’t move — all your valuable equipment is just too big and heavy and if you move it, you will destroy it all.  You’re stuck.  Pretty inconvenient wrench thrown in your growth plans…

Web Developer:
“Look, CEO Bill, your customers are your most important asset, but understanding their wants and needs is the key to growing profits.  That means you need information about them, how to reach them, how to inspire them to act — your information and systems all rely on a database that needs to collect all vital customer, product, marketing, and company information that can work together to maximize sales outcomes because information and marketing working together will not just keep your business afloat, it will help you reach new heights.”

CEO Bill smiles admiringly:
“Well that’s right, for the most part.  But customer service, relationship building and word-of-mouth all existed before a database.”

Web Developer:
“Well, you didn’t store information about your customers on a computer, but you kept records, they were on paper and probably stacked in boxes that took a long time to sift through to make any sense out of it.  Imagine all the information that was never read that could have helped you make better decisions faster to help improve sales — all the opportunities for new ideas and innovation never saw the light of day because all that information was collected but painful to retrieve.  Wouldn’t you want to have more useful information with less hassle?”

CEO:
“Sure.”

Web Developer:
“Imagine if you were stuck with an antiquated database system that broke a lot and didn’t give you much useful or reliable information, not to mention the fact that it didn’t help you automate a lot of your systems that cost you hundreds, possibly thousands of hours in manual labor every year.  If we take the time and deliberately plan your needs and design a system, database and infrastructure that can support your company needs well into the future, you will save more money in efficiencies and make more money in new revenue and marketing opportunities than doing nothing.”

Don’t get entangled in “web development strangulation”

Because improving your data and systems will almost always result in much higher efficiencies and profits, even in the short run, you need a web developer who will be honest with you.  You also need to stay far away from those who call themselves web developers who write code to entrap “customers for life”.  You know the symptoms, perhaps you’ve been a victim of it yourself.  Why does it take so long to make a small change to your website, Intranet portal, or some backend report?  If you often ask or hear this question, this is a symptom of concern for your company — you are wasting time and energy and probably have wasted a lot of time, energy and money getting in the mess you’re in now — “entangled code”, you are an unknowing victim of “web development strangulation.”

First of all, no real web developer worth their salt wants to keep going back to the same project over and over and fixing things they intentionally sabotaged just to keep their job.  I’d die of boredom!  Yet, many developers create complex monsters for three reasons, and three reasons only:

  1. They don’t know what they’re doing, so they “wing-it” and go on Google and slap things together until they work.
  2. They intentionally design in an over-complex way to ensure that no one else could grasp or understand, much less fix or easily replace code they’ve written in the past.
  3. They really don’t know what they’re doing.

The real test is if a web developer writes code and acts like they don’t want to see this project again so they spend enough time designing, thinking, planning and writing code properly so they can move onto more challenging and exciting projects.  Just be sure they showed you enough of the plans and the thought that went into the design of your new systems and databases and be sure to ask what their plans are if the company out grows the system or if they decide to change database systems.  If they look at you horrified, chances are they haven’t been exposed to ORMs.  Mention that you insist on future compatibility and scalability and ask them if they do not recommend using an ORM in your system now, how would they plan on accommodating your company’s plans for growth later?

Using an ORM isn’t even that much more effort on the front end, but knowing you everything you need is neatly ready for scaling and portability is another positive in your company’s asset column that will inevitably bring you more revenue into your P & Ls.

– Aaron Belchamber


As you scan your site for opportunities to optimize, your SEO results will probably tell you that on certain pages of your website you have two or more H1 tags.  By far not the most egregious of violations, you don’t want to confuse those simple-minded robots called search engines that can’t figure out the first H1 tag is more important than the second <h1> tag when they crawl each document on your site much like they already assume with HTML 5 and <header> tags which they encounter more and more every day.

That being said, pre HTML5 pages should abide by the general rule that you should only use ONE H1 tag per page — if nothing else to pay homage to those reminiscent times of rogue, cowboy coding with little restrictions and standards that brought us such great innovations as link farms and “what else can we do to trick the search engines because we’re too lazy to focus on actually building our business” strategies that still seem to prevail throughout the web.

If you are using WordPress and a Genesis theme, you might do a lot of googling before coming across this snippet.  How do you shut off the H1 tag in the WordPress headers on every page but the homepage in this darn framework?!  As much as I like Genesis, they should have a simple guide or cheat sheet for all their extended functions based on the WordPress core.  Don’t you love those themes and plug-ins that make you type their name in every instance within your code?  They may think having to type “genesis” everywhere is a form of branding, to me, it’s the kind of painful branding I try to avoid — much like the gasp of pain a cow would make after getting branded with a hot iron.


/**
  *    Remove Site title tag if not homepage
**/

add_filter( ‘genesis_seo_title’,’conditional_title’ );

function conditional_title($title) {
if ( !is_front_page() ) :
     $title = ”;
   return;
   else :
    return $title;
   endif;
}

Don’t get me wrong, I think Genesis is a good Theme Framework for WordPress, they have excellent products and support, but wouldn’t an option to just type “gen_” do?! Anyway, here’s the fix based on the problem mentioned in the title. Aaron Belchamber


When you are working on your website, you frequently visit it so your browser caches a lot of content.  If you’re not careful, it’s easy to assume what YOU experience on your browser is how the rest of the world will experience it.  NEVER assume and clear your browser’s cookies and cache, also called “Temporary Files”.  Test your site in different browsers and on different devices frequently.  Often, different browsers will display pages differently and you may find pages don’t display at all in Google Chrome but fine in Firefox.

Using an independent website tool to check the status of your site and certain pages is critical to making sure you find potential issues with your website before your visitors encounter them.  This will give you time to fix issues so the UX — “user experience” is optimal.  Remember, if your site loads slowly or shows other issues, people will leave.  The more frequently such a bad experience happens the more the chance that they will also never come back.  That’s bad for traffic and worse for your business.
pingdom-tools-screenshot

I suggest going to Pingdom and test your own website.  It’s a pretty straight forward process as you will just need to enter your domain name in the field and click “Test Now”.  They go pretty deep with their analytics and have other options to also test your website’s DNS records, too.  To make sure your site, server and DNS records are all optimized, this is another step that you should add in your web development deployment and maintenance checklist.

If Pingdom detects any issues with your site, these tools will help you pinpoint the problem areas, like a slow-loading image or a Javascript library that takes too long to load.  The issues Pingdom’s tools detect will then help you resolve them.  You can even subscribe and have Pingdom monitor your website to ensure it is up and running and it will also alert you by email or text if there is something wrong with your website.  For e-commerce and websites critical to your company’s profit model, this is a small investment to stay on top of your website.