<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Tue, 18 Jun 2013 22:09:10 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Rasmus Larsson: Building a template engine in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/19655</guid>
      <link>http://www.phpdeveloper.org/news/19655</link>
      <description><![CDATA[<p>
<i>Rasmus Larsson</i> has a recent post to his site showing how to <a href="http://www.rasmuslarsson.se/2013/05/a-template-engine-in-php/">build a basic templating engine</a> in PHP that uses the "__toString" to help render the result.
</p>
<blockquote>
Possibly the most common sign of bad code is tight coupling, especially between logic and presentation. It might seem like a good idea to print out the HTML while the data is being generated, but it more often than not leads to a big incoherent mess of tangled code. [...] While PHP makes it unnecessarily easy to write shitty code it also provides a lot of ways to avoid it. I'll use this post to show you how ridiculously easy it is to create a template engine in PHP in three easy steps.
</blockquote>
<p>
He includes the sample code for a "Template" class and shows the combination of <a href="http://php.net/export">export</a>ing variables and output buffering to return the resulting template populated with values. The "__toString" method makes it so that you can just <a href="http://php.net/echo">echo</a> out the object and get the results.
</p>
Link: http://www.rasmuslarsson.se/2013/05/a-template-engine-in-php]]></description>
      <pubDate>Fri, 31 May 2013 11:11:27 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[System Architect: Integrate PHP application with Solr search engine]]></title>
      <guid>http://www.phpdeveloper.org/news/19303</guid>
      <link>http://www.phpdeveloper.org/news/19303</link>
      <description><![CDATA[<p>
On the "System Architect" site there's a recent post showing you how to <a href="http://systemsarchitect.net/integrate-php-application-with-solr-search-engine/">integrate PHP and Solr</a>, the searching tool from the Apache project.
</p>
<blockquote>
So why do you need a search engine, is database not enough? If you create a small website it might not matter. With medium or big size applications it's often wiser to go for a search engine. Saying that, even a small websites can benefit from Solr if you desire a high level of relevance in search results.
</blockquote>
<p>
Their example involves an ecommerce website and a search for a term (iPhones) and how difficult it could be to match against the possible multiple variations on the models. Solr makes this kind of searching easier. He shows you how to get a Solr instance all set up and configured as well as the PHP PECL extension from <a href="https://github.com/lukaszkujawa/php-pecl-solr.git">here</a>. A sample PHP script is also included showing connecting to Solr, inserting a new document and searching for a simple query of "hello". 
</p>]]></description>
      <pubDate>Tue, 12 Mar 2013 12:01:43 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Kevin Schroeder: Would this be a dumb idea for PHP core?]]></title>
      <guid>http://www.phpdeveloper.org/news/19200</guid>
      <link>http://www.phpdeveloper.org/news/19200</link>
      <description><![CDATA[<p>
In <a href="http://www.eschrade.com/page/would-this-be-a-dumb-idea-for-php-core">this new post</a> to his site <i>Kevin Schroeder</i> thinks out loud and wonders if an idea of his is "a dumb idea" to be included into the PHP core - engine state caching.
</p>
<blockquote>
 I was consulting and I would see significant server resources consumed by bootstrapping the apps.  Loading config files, loading dependent classes, setting up dependencies, initializing ACL's, and the list goes on and on. One of the ways to negate the effect would be to cache a bootstrap object and then pull that object from the cache at the start of the request.  However, the problem is that unserialization can actually end up taking more time than the bootstrap process itself.
</blockquote>
<p>
He wonders if, after the initial bootstrapping happened, a method could be called (his example is "init_engine_state") that would cache the Zend Engine's current state and pass that to a callback function. This would cache everything - objects, variables, classes, etc - all pre-interpreted into memory and make them easy to reuse on future executions. What do you think? <a href="http://www.eschrade.com/page/would-this-be-a-dumb-idea-for-php-core">Share your thoughts</a> in the comments of the post.
</p>]]></description>
      <pubDate>Tue, 19 Feb 2013 09:26:55 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[WorkingSoftware Blog: Your templating engine sucks & everything you've written is spaghetti code]]></title>
      <guid>http://www.phpdeveloper.org/news/17259</guid>
      <link>http://www.phpdeveloper.org/news/17259</link>
      <description><![CDATA[<p>
In a bit of a ranting post on the WorkingSoftware.com.au blog <i>Iain Dooley</i> shares his opinion about most of the code he's seen, specifically related to templating engines: "Your templating engine sucks and everything you have ever written is spaghetti code (yes, you)".
</p>
<blockquote>
Templating is a real hot button in the web development community. [...] The high horses that people usually get on are that all too familiar TLA MVC (Model/View/Controller) architecture and "separation of presentation and business logic". The poor pedestrians upon which they look down are those who have written "spaghetti code" - templates where presentation logic, markup, business logic, database access configuration and whatever else you might imagine are mixed up in the same file. Well, I've got some news for you: you're all wrong.
</blockquote>
<p>
He points out that, with most of the major templating tools out there, there's most people still put some sort of business logic in their templates. Rarely will you find a "pure" template that only echoes out the data. He gives an example of a <a href="http://mustache.github.com">Mustache</a> template with "empty" logic in it. He shares a new term his coined too: "Template Animation". This is the separation of the templating process as it is usually done and splitting it so that the output is a modified DOM resource rather than a static template. 
</p>
<p>
He talks about some of the advantages of this approach and an example of its use in an example of a logged in user vs not logged in user as well as a brief discussion of Markdown/HAML.
</p>
<blockquote>
The only thing that Template Animation advocates is that the technological barrier between the frontend and the backend is never crossed - that our templates are truly logic-less.
</blockquote>
<p>
There's <a href="http://www.workingsoftware.com.au/page/Your_templating_engine_sucks_and_everything_you_have_ever_written_is_spaghetti_code_yes_you">lots of comments on the post</a> already - everything from support of the idea to systems that already implement this sort of idea to disagreeing opinions.
</p>]]></description>
      <pubDate>Wed, 14 Dec 2011 12:03:54 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Sameer Borate's Blog: Grabbing the referrer search engine keywords for a site]]></title>
      <guid>http://www.phpdeveloper.org/news/17009</guid>
      <link>http://www.phpdeveloper.org/news/17009</link>
      <description><![CDATA[<p>
On his blog today <i>Sameer Borate</i> has a new post with a handy bit of code you can use to <a href="http://www.codediesel.com/php/grabbing-the-referrer-search-engine-keywords-for-a-site/">find the keywords from a search engine referral</a> to help with tracking how visitors have come to your site.
</p>
<blockquote>
A couple of weeks back I had to write a solution for a client to track the referrer search engine from where the user came to his sites contact page, without using Google Analytics. If a user was to fill the contact form on the website, the referring search engine name and the keyword for which it was refereed was to be emailed along with the contact information. The following is a solution for the same.
</blockquote>
<p>
The code itself is pretty simple - it checks the $_SERVER['HTTP_REFERER'] and, based on an array of search engine types, looks for a certain "query" keyname in the URL and matches what follows (with <a href="http://php.net/preg_match">a regular expression</a>). This can be useful for not only determining what sort of audience is visiting your site, but could also be used to present a custom message to visitors from certain search engines (or, more complicated, to show different content based on search terms).
</p>]]></description>
      <pubDate>Tue, 18 Oct 2011 13:25:27 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPBuilder.com: 5 Popular PHP Template Engines Worth Checking Out]]></title>
      <guid>http://www.phpdeveloper.org/news/16168</guid>
      <link>http://www.phpdeveloper.org/news/16168</link>
      <description><![CDATA[<p>
On PHPBuilder.com today there's a new article looking at <a href="http://www.phpbuilder.com/columns/5-template-engines/Jason_Gilmore04072011.php3">five PHP templating engines</a> that they think are worth a look for use in your next project (or maybe in a current one).
</p>
<blockquote>
In this article I'll introduce five of PHP's most popular templating engines, providing you with a basis for continuing your own investigations. Keep in mind however that this list is by no means definitive; if you have experience using a templating engine not discussed here, please tell us about it in the comments!
</blockquote>
<p>The five template engines the author chose to spotlight are:</p>
<ul>
<li>Smarty
<li>Dwoo
<li>Twig
<li>Savant3
<li>PHPTal
</ul>
<p>
Each comes with a description of its major features and a code snippet or two showing it in use.
</p>]]></description>
      <pubDate>Fri, 08 Apr 2011 13:23:40 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Webification.com: Roundup of 17 Best PHP Template Engines]]></title>
      <guid>http://www.phpdeveloper.org/news/16004</guid>
      <link>http://www.phpdeveloper.org/news/16004</link>
      <description><![CDATA[<p>
Webification has put together <a href="http://webification.com/best-php-template-engines">a comparison of template engines</a> that the PHP world has to offer. Their list is 17 of the most popular described and compared against one another based on features.
</p>
<blockquote>
When we think about PHP Template Engine, the most famous library is certainly Smarty. However, we may consider other alternatives to Smarty. In this post we have collected 16 template engines written in PHP that allow you to separate HTML code from PHP code.
</blockquote>
<p>Among those on the list are templating engines like:</p>
<ul>
<li><a href="http://www.smarty.net/">Smarty</a>
<li><a href="http://phpsavant.com/">Savant</a>
<li><a href="http://dwoo.org/">Dwoo</a>
<li><a href="http://www.phpxtemplate.org/">PHP XTemplate</a>
<li><a href="http://www.h2o-template.org/">h2o-php</a>
</ul>]]></description>
      <pubDate>Mon, 07 Mar 2011 09:18:52 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: PHP Template Engine Comparison. Part 2 (vs Plain PHP)]]></title>
      <guid>http://www.phpdeveloper.org/news/15794</guid>
      <link>http://www.phpdeveloper.org/news/15794</link>
      <description><![CDATA[<p>
Following in the heels of his <a href="http://phpdeveloper.org/news/15748">first post</a> looking at a few of the templating offerings available to PHP applications, <i>Gonzalo Ayuso</i> is back with <a href="http://gonzalo123.wordpress.com/2011/01/24/php-template-engine-comparison-part-2-versus-plain-php/">part two</a> - a comparison versus just "plain PHP".
</p>
<blockquote>
In my <a href="http://gonzalo123.wordpress.com/2011/01/17/php-template-engine-comparison/">last</a> post I created a small (and very personal) test of different templating engines in PHP (Smarty, Haanga and Twiw). Someone posted a comment asking for the comparison between those template engines and old school phtml. OK I've done some tests. It's a bit difficult to create the template inheritance (without cloning one of the template engines and creating a new one) so I have one approximation with a simple include. It's not the same but it's similar.
</blockquote>
<p>
He tries to recreate a similar scenario as in the three other templating tools by setting up a base template (with inline PHP), a class to populate the contents of it and a sample template with "inheritance". He stacks up the execution times and memory usage against the results from the other three with interesting results, specifically compared to <a href="http://www.haanga.org">Haanga</a>.
</p>]]></description>
      <pubDate>Mon, 24 Jan 2011 11:11:07 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: PHP Template Engine Comparison]]></title>
      <guid>http://www.phpdeveloper.org/news/15748</guid>
      <link>http://www.phpdeveloper.org/news/15748</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Gonzalo Ayuso</i> has put together a comparison of a few <a href="http://gonzalo123.wordpress.com/2011/01/17/php-template-engine-comparison/">PHP templating alternatives</a> out there developers can use to further separate the view logic from the main parts of their application.
</p>
<blockquote>
Template engines has a lot of features but I normally only use a few of them and the other features very seldom. In this performance test I will check the same features under different template engines to see the syntax differences and the performance. The template engines selected for the test are <a href="http://www.smarty.net/">Smarty</a>, <a href="http://www.twig-project.org/">Twig</a> and <a href="http://haanga.org/">Haanga</a>.
</blockquote>
<p>
He does some testing with each, creating a basic template to loop and create a basic table (template code and PHP code included) as well as an example using template inheritance with each. The reports of his tests are shared at the end with stats for memory used and execution time for both the normal templates and the inherited versions - but you'll have to <a href="http://gonzalo123.wordpress.com/2011/01/17/php-template-engine-comparison/">check out the post</a> for those results.
</p>]]></description>
      <pubDate>Mon, 17 Jan 2011 08:16:37 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Zend Developer Zone: Building Template-Driven Web Applications with Dwoo (part 2)]]></title>
      <guid>http://www.phpdeveloper.org/news/14926</guid>
      <link>http://www.phpdeveloper.org/news/14926</link>
      <description><![CDATA[<p>
On the Zend Developer Zone the <a href="http://devzone.zend.com/article/12366-Building-Template-Driven-Web-Applications-with-Dwoo-part-2">second part of their series</a> on templating with the <a href="http://dwoo.org">Dwoo</a> PHP5 framework. (Here's <a href="http://phpdeveloper.org/news/14827">part one</a>.)
</p>
<blockquote>
In the previous segment of this article, I introduced you to Dwoo, a powerful, PHP 5.x template engine that allows Web application developers easily separate the user interface of their application from its business logic. [...] In this second, and concluding, segment, I'll delve a little deeper, exploring some of Dwoo's lesser-known features.
</blockquote>
<p>
He talks about the ability for template inheritance, creating sub-templates (like partial views), plugins available, mail merging, caching and how to use it as the templating engine in your framework of choice.
</p>]]></description>
      <pubDate>Mon, 09 Aug 2010 11:50:41 -0500</pubDate>
    </item>
  </channel>
</rss>
