 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
System Architect: Integrate PHP application with Solr search engine
by Chris Cornutt March 12, 2013 @ 12:01:43
On the "System Architect" site there's a recent post showing you how to integrate PHP and Solr, the searching tool from the Apache project.
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.
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 here. A sample PHP script is also included showing connecting to Solr, inserting a new document and searching for a simple query of "hello".
voice your opinion now!
solr search engine tutorial integration pecl extension
Kevin Schroeder: Would this be a dumb idea for PHP core?
by Chris Cornutt February 19, 2013 @ 09:26:55
In this new post to his site Kevin Schroeder thinks out loud and wonders if an idea of his is "a dumb idea" to be included into the PHP core - engine state caching.
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.
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? Share your thoughts in the comments of the post.
voice your opinion now!
engine state cache zendengine bootstrap callback
WorkingSoftware Blog: Your templating engine sucks & everything you've written is spaghetti code
by Chris Cornutt December 14, 2011 @ 12:03:54
In a bit of a ranting post on the WorkingSoftware.com.au blog Iain Dooley 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)".
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.
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 Mustache 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.
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.
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.
There's lots of comments on the post already - everything from support of the idea to systems that already implement this sort of idea to disagreeing opinions.
voice your opinion now!
opinion templating engine logic separation templateanimation
Sameer Borate's Blog: Grabbing the referrer search engine keywords for a site
by Chris Cornutt October 18, 2011 @ 13:25:27
On his blog today Sameer Borate has a new post with a handy bit of code you can use to find the keywords from a search engine referral to help with tracking how visitors have come to your site.
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.
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 regular expression). 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).
voice your opinion now!
search engine keyword referrer url snippet
PHPBuilder.com: 5 Popular PHP Template Engines Worth Checking Out
by Chris Cornutt April 08, 2011 @ 13:23:40
On PHPBuilder.com today there's a new article looking at five PHP templating engines that they think are worth a look for use in your next project (or maybe in a current one).
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!
The five template engines the author chose to spotlight are:
- Smarty
- Dwoo
- Twig
- Savant3
- PHPTal
Each comes with a description of its major features and a code snippet or two showing it in use.
voice your opinion now!
template engine twig dwoo savant3 smarty phptal
Gonzalo Ayuso's Blog: PHP Template Engine Comparison. Part 2 (vs Plain PHP)
by Chris Cornutt January 24, 2011 @ 11:11:07
Following in the heels of his first post looking at a few of the templating offerings available to PHP applications, Gonzalo Ayuso is back with part two - a comparison versus just "plain PHP".
In my last 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.
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 Haanga.
voice your opinion now!
template engine compare benchmark plain base
Gonzalo Ayuso's Blog: PHP Template Engine Comparison
by Chris Cornutt January 17, 2011 @ 08:16:37
In a new post to his blog Gonzalo Ayuso has put together a comparison of a few PHP templating alternatives out there developers can use to further separate the view logic from the main parts of their application.
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 Smarty, Twig and Haanga.
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 check out the post for those results.
voice your opinion now!
template engine compare benchmark twig haanga smarty
Zend Developer Zone: Building Template-Driven Web Applications with Dwoo (part 2)
by Chris Cornutt August 09, 2010 @ 11:50:41
On the Zend Developer Zone the second part of their series on templating with the Dwoo PHP5 framework. (Here's part one.)
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.
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.
voice your opinion now!
plugin dwoo template engine framework
Fabien Potencier's Blog: Templating Engines in PHP
by Chris Cornutt October 08, 2009 @ 07:51:37
New on his blog today Fabien Potencier tackles a tough topic for the PHP community - templating languages and whether or not their that useful/good after all.
So, you think PHP is a templating engine? So did I... for a very long time. But recently, I changed my mind. Even if PHP can be used as a templating engine, the syntax is just plain ugly as a template language. [...] So, when I asked a few days ago about the best and popular templating engines in PHP on Twitter, some people naturally answered "PHP" itself. I was not even surprised as that would probably have been my answer some weeks ago too.
He suggests that PHP, by itself, just isn't good enough any more and that truly robust templating languages (no, not like that one) can make a huge improvement in the quality of your application. He touches on a few related points including reusability, security and some of the current templating tools for PHP - Smarty, PHPTAL, eZ Components templates, Dwoo, Calypso and his own incarnation - Twig. He also includes some stats on rendering times and memory usage for each.
UPDATE: After all of the response that the PHP gave back to this article, Fabien also posted a follow-up with a bit more information on Twig.
voice your opinion now!
template engine language twig
|
Community Events
Don't see your event here? Let us know!
|