 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
DevShed: Using Closures as View Helpers
by Chris Cornutt January 25, 2012 @ 09:50:38
New on DevShed today there's a tutorial looking at using one of the newer features of PHP, closures, as view helpers in a basic templating system.
In this two-part tutorial I'll be showing you, in a step-by-step fashion, how to use the goodies offered by closures in the implementation of an object-based, easily extendable template system. This system will allow you to embed anonymous functions easily into template files, and call them as typical view helpers, too.
He starts the process of creating the templating system by defining two interfaces, the View and DataHandler. Using these as a base, he creates an instance of the ViewInterface (a "View" class) that can set the template file to use, set values to be displayed and render the formatted output. Included is a basic template and how to use the View class to set values into it. The "render" method is called on the view and the HTML markup is produced. The closure comes in when they try to call a value "clientIp" that needs to do something more complicated than just having a string assigned to it.
voice your opinion now!
closure view helper template view interface
Derick Rethans' Blog: Twig extension
by Chris Cornutt November 21, 2011 @ 08:35:39
In a new post from Derick Rethans he talks about an extension version of Twig, the popular templating engine from the creators of the Symfony framework.
A while ago, Fabien asked me to have a look at porting one of Twig's slowest methods, TwigTemplate::getAttribute(), into a PHP extension. It is a complex method that does a lot of different checks and look-ups. Fabien's benchmarks showed that this method was responsible for quite a large amount of time. On top of that, it didn't seem that it could be optimised any further as PHP code itself.
He points to the twig-ext extension that's a reworked version of the "getAttribute" method from the tool and the performance gain (about 15%) it gives. Compiled templates will automatically call this new method in the extension. This update has already been merged into the main Twig repo.
voice your opinion now!
twig extension template language symfony speed
PHPMaster.com: Code Templates, AutoHotKey, and Ditto Speeding Up Development
by Chris Cornutt November 07, 2011 @ 11:13:20
On PHPMaster.com today they share a list of helpful tools and tricks that you can apply not only to your PHP development, but programming in general. They highlight code templates, using hotkeys and Ditto.
There are also other helpful pieces of software such as libraries, code snippets, and third party applications. In this article I'll show you how I use a feature built into NetBeans along with two other applications to increase my productivity when programming on Windows. These tips and techniques offer a different way of thinking about things which should be helpful to any developer, regardless of his skill level.
They start with a look at the Code Templates available in NetBeans (other IDEs/editors have a similar feature) to provide an easier starting place for your code, a tool called AutoHotKey that lets you define custom hotkey shortcuts and Ditto, a clipboard manager that lets you manage your copy/pasting better than the single-shot functionality Windows normally has.
voice your opinion now!
code template hotkey clipboard management autohotkey dittio development tool
DZone.com: Closure Object Binding in PHP 5.4
by Chris Cornutt October 28, 2011 @ 08:43:26
In a new post to DZone.com Mitchell Pronschinske looks at closure object binding in PHP 5.4 applications (yes, we know PHP 5.4 isn't released yet). He explains what this is an shows some sample use cases for you to consider in your development.
For the people who read PHP's NEWS file, it's no surprise - but for all who don't here's is probably one of the biggest features of PHP 5.4: Closure Object Support is back. For me it's something I missed the most, when Closures were introduced in PHP 5.3. So I'm very happy, that's finally here (or back). I'm going to tell you about the rocky road which closure object binding support had and show you some simple use cases for it.
The functionality, based on this RFC, lets you more correctly bind closures to objects instead of having to pass the objects into the closure at create time. He includes an example from a Silex framework application and an example that refactors a helper method as a part of rendering a simple template.
voice your opinion now!
object binding support tutorial template example
PHPBuilder.com: Getting Started with Jenkins for PHP Developers
by Chris Cornutt June 22, 2011 @ 09:20:26
On PHPBuilder.com today there's a new tutorial from Jason Gilmore helping you get started with Jenkins for building and deploying your PHP applications. Jenkins (formerly Hudson) can make things "one click simple" for you to correctly push your applications live every time.
Although a Java-based solution, an active plugin community has made it possible to use Jenkins for far more than Java-specific projects. More recently it has become much easier for Jenkins' novices to use the project in conjunction with PHP projects thanks to the work of Sebastian Bergmann. Known as Template for Jenkins Jobs for PHP Projects, the project provides a configuration file which you'll use to enable Jenkins/PHP integration, and supports several popular familiar PHP tools such as PHP_CodeSniffer and PHPUnit.
He walks you through a brief installation of Jenkins (packages on a Debian install) and shows you how to get your git repository, the source for it to pull from) configured and ready to pull. He also includes some other screenshots showing you where to look for the build status, results from past builds and how to get the system to build documentation as a part of the build.
voice your opinion now!
jenkins install tutorial build template deploy git
Zend Developer Zone: Creating Web Page Templates with PHP and Twig (part 2)
by Chris Cornutt May 05, 2011 @ 13:11:25
On the Zend Developer Zone they've posted the second part of Vikram Vaswani's look at using the Twig templating engine in your PHP applications. In the first part of the series, he introduced the tool and got started with some simple examples. In this second part, he dives in deeper to some of the advanced features.
In this second and concluding segment, I'll look at some of Twig's other features, including such goodies as template inheritance, custom filters and caching. If you enjoyed the first part of this article, keep reading to find out more about what goes on under Twig's hood, and how you can add even more power and flexibility to your templates
He looks at template inheritance, parent blocks/child templates, data filtering, the tool's "compilation cache" and working with native plugins.
voice your opinion now!
twig template tutorial inheritance filter cache plugin
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
|
Community Events
Don't see your event here? Let us know!
|