 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
DevShed: PHP Closures as View Helpers Lazy-Loading File Data
by Chris Cornutt January 30, 2012 @ 13:08:28
In the second part of their look at using closures in PHP as view helpers, DevShed improves upon their original code by adding some additional classes and using them in the closures.
The best way to show you how using anonymous functions can help you to develop more efficient OO applications is with some functional, hands-on examples. With this idea in mind, in the installment that preceded this one, I implemented an extendable template system. This system could spawn view objects and render the template files associated with these objects.
In this second part of the (two-part) series they include "Serializer" and "FileHandler" classes and show how to use them inside of the closures to lazy-load in data from an external file and work with it as serialized content.
voice your opinion now!
tutorial closure lazyload file serialize view helper
Project: Patchwork-UTF8 - UTF8 Support for PHP
by Chris Cornutt January 27, 2012 @ 11:38:40
Nicolas Grekas has shared another tool that he's pulled out of his "Patchwork" framework to make it a stand-alone tool: the Patchwork-UTF8 helper that provides matching functions to those PHP already has for regular strings, but a little smarter to work with UTF8 correctly.
The PatchworkUtf8 class implements the quasi complete set of string functions that need UTF-8 grapheme clusters awareness. These functions are all static methods of the PatchworkUtf8 class. The best way to use them is to add a use PatchworkUtf8 as u; at the beginning of your files, then when UTF-8 awareness is required, prefix by u:: when calling them.
In the README for the tool he talks about the functions included in the current release that match PHP's string functions as well as some additional methods like "isUtf8", "bestFit" and "strtocasefold". It relies on the mbstring, iconv and intl extensions being installed, and if they aren't, it falls back to other functionality (list of those methods included).
voice your opinion now!
utf8 support string patchwork framework helper mbstring iconv intl
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
Anna Filina's Blog: Integrating Markdown with Symfony
by Chris Cornutt April 26, 2011 @ 10:56:46
Anna Filina has a new post showing how you can integrate a documentation format that's become a bit more popular recently (due partially to its increased use on github), Markdown, into a Symfony application.
I needed to create a number of static help pages in three languages in a Symfony 1.4 application. Using the XLIFF translation files seemed absurd, since I knew that I will include a lot of HTML. [...] And so, I decided to create partials using the following structure: _docs/{lang}/{title}.php. This method would organize my pages nicely and will only load what is needed. Then, I remembered that we were planning to hire a technical writer for the rest of the manual. I wanted to make his life as easy as possible and the source files easy to read for everyone.
She found the solution in Markdown and has included a step-by-step guide to getting it integrated with Symfony using this parser. It's loaded as a helper and used to parse the partial view's content. You can find a quick guide to Markdown on the Daring Fireball website.
voice your opinion now!
markdown symfony framework helper view
Rob Allen's Blog: Zend Framework View Helpers
by Chris Cornutt March 14, 2011 @ 12:56:18
Rob Allen has written up a post today consolidating some of the knowledge he has about using view helpers in the Zend Framework, starting with the basics and some code along the way.
Zend Framework's Zend_View component supports helper methods known as view helpers. [...] typical Zend Framework project using Zend_Application, such as that generated using the zf command line tool, will have a folder called helpers within the views folder for each module. There will also be a helpers folder within the layouts folder too.
He goes on to show how to introduce custom view helpers into your application and how extending the Zend_View_Helper_Abstract class gives you access to many of the common view functions (like "escape").
voice your opinion now!
view helper zendframework introduction
Community News: DBG Debugger Helper for Google Chrome Released
by Chris Cornutt December 27, 2010 @ 13:56:34
Jeremy Cook sent in a new tip about a new debugging extension for Google Chrome that hooks into the DBG debugger to help you test your PHP applications - a DBG Debugger Helper (currently in version 0.0.0.1).
For those using the DBG debugger for PHP development, this minimal extension provides a convenient way to initiate debugging and profiling sessions. The most likely users will be anyone using Nusphere's PhpED. This commercial PHP IDE includes a robust, up-to-date, and full-featured DBG debugger. [...] Installation, configuration, and use is quick and simple. While you can configure the clienthost, port, and session ID entries of the Options dialog, this is not required.
The extension makes it as simple as one click to start and stop the debugging process that will watch round trip requests and catch errors to allow DBG to provide things like backtraces, work through the script step by step.
voice your opinion now!
google chrome helper dbg debugger helper
Rob Allen's Blog: View helpers in modules
by Chris Cornutt December 13, 2010 @ 10:04:15
Rob Allen has this quick new post to his blog today for those out there developing with the Zend Framework - how to use view helpers inside modules.
I came across a situation last week where I needed to access a view helper that was in the default module's views/helpers directory when I was in another module. This came about because my layout.phtml uses a view helper that is in application/views/helpers.
An error's thrown if you try to use it normally, something about a plugin not being found. The key fix is an easy one, though - add a new Zend_View_Helper path and a helperPath for the module you want to use them in inside the application.ini file.
voice your opinion now!
view helper module zendframework
Matthew Weier O'Phinney's Blog: Using Action Helpers To Implement Re-Usable Widgets
by Chris Cornutt October 05, 2010 @ 09:12:19
Matthew Weier O'Phinney has a new post to his blog today showing you how to use action helpers to make widgets that you can reuse all over your Zend Framework application. His method doesn't use the "action()" helper, either.
The situation all started when Andries tweeted asking about what he considered some mis-behavior on the part of the action() view helper -- a situation that turned out not to be an issue, per se, but more a case of bad architecture within Zend Framework. [...] The helper was done this way because Zend Framework does not render views a single time -- it instead renders after each action, and accumulates views to render in the layout.
Instead, he offers action helpers as a solution. He gives an example of a user module that has views, helpers and forms but no controllers, including a Bootstrap file. This bootstrap defines the helpers, configuration file and adds the helpers into the process flow of the application. Once things are all set up and the action helper is created, adding the module to a page is as easy as calling "createProfileWidget()" into a partial view.
voice your opinion now!
action helper zendframework widget reuse tutorial
PHPBuilder.com: Use Zend Framework Action Helpers to Reduce PHP Code Redundancy
by Chris Cornutt September 15, 2010 @ 11:49:52
On PHPBuilder.com today there's a new tutorial from Jason Gilmore about using the action helpers in the Zend Framework to help reduce the amount of redundant code spread all over your application.
Embracing a framework-driven approach to Web development enhances productivity in many ways, not the least of which is the ability to stay DRY (Don't Repeat Yourself). Eliminating the redundant reuse of code throughout a Web application will greatly improve your ability to effectively test and later refactor code, not to mention locate and diagnose the inevitable bugs that will creep into the project. [...] The Zend Framework refers to these reusable logical snippets as action helpers, and in this article I'll show you how to create, configure and execute action helpers within your Zend Framework-powered applications.
He walks you through the steps of creating an action helper to create a simple one-time URL for an example application's email confirmation links. The class (WJG_Controller_Action_Helper_GenerateID) extends the abstract action controller and generates the code to append to the URL. When the code is needed, the helper can just be called directly and the string is returned for use in multiple types of emails.
voice your opinion now!
code redundancy zendframework action helper tutorial
|
Community Events
Don't see your event here? Let us know!
|