 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Stefan Koopmanschap's Blog: Using custom namespaces with (C/S)ilex and Composer
by Chris Cornutt April 12, 2012 @ 12:22:47
Stefan Koopmanschap has a quick new post to his blog with a handy tip for Composer and Cilex/Silex users when dealing with custom namespaces.
For a new proof of concept application I'm building, I need both a simple web interface as well as some commandline tools. I decided to use Silex for the web interface and Cilex for the CLI tools, and opted for using Composer for installing these dependencies into my project. I ran into some issues with the custom project libraries I was building for this application however. Registering my custom namespace into Silex and Cilex didn't result in the classes being loaded for some reason. Composer helped me out though.
His solution involves letting Composer be the default autoloader for the application via an "autoloader" configuration option in the "composer.json" (that can also take a classmap option if you're not PSR-0 compliant, see here).
voice your opinion now!
custom namespace cilex silex composer psr0 autoloader
Rob Allen's Blog: Using ZendLoaderAutoloader
by Chris Cornutt February 13, 2012 @ 09:54:43
In a new post to his blog Rob Allen introduces you to the autoloader that comes with the Zend Framework 2 and shows how to use it to load your own classes.
Autoloading is the process in PHP whereby the system attempts to load a class when it is first encountered (via new or via class_exists) if it hasn't already been loaded via a require or include. Autoload works by looking for a method called __autoload or walking through any method registered with spl_autoload_register. Zend Framework 2 provides the ZendLoaderAutoloader component for autoloading of Zend Framework and your own classes.
The PSR-0-standard tool allows you to load files, set up class mapping and allows for multiple autoloading methods to work side-by-side. He shows how to use the standard autoloading functionality to define paths to locate files (with prefixes and namespaces) in both a constructor-based setup and a more programatic approach. He also shows how to use the ClassMapAutoloader to load from a mapping of class name to class file. Wrapping it up, he shows how to combine the two methods into a single ZendLoaderAutoloaderFactory instance.
voice your opinion now!
zendframework autoloader classmap standard tutorial
Matthew Weier O'Phinney's Blog: Backported ZF2 Autoloaders
by Chris Cornutt May 11, 2011 @ 09:33:20
In a new post Matthew Weier O'Phinney talks about autoloaders in the Zend Framework and the changes they've made from ZF1 to ZF2. He also includes a link to a package you can try out if you'd like to backport the ZF2 autoloaders to your ZF1 application.
Interestingly, I've had quite some number of folks ask if they can use the new autoloaders in their Zend Framework 1 development. The short answer is "yes," assuming you're running PHP 5.3 already. If not, however, until today, the answer has been "no."
I've recently backported the ZF2 autoloaders to PHP 5.2, and posted them on GitHub [tarball here].
His autoloader backport scripts include a class map generation tool, a PSR-0 compliant autoloader, a class map autoloader and an autoloader factory for loading multple strategies at once. He also includes a sample of how to use it with a bit of the output it might give you for your project.
voice your opinion now!
zendframework autoloader backport github
Volker Dusch's Blog: Autoloading for legacy, non-framework projects
by Chris Cornutt March 09, 2011 @ 12:02:06
In his latest post Volker looks at something he sees more and more projected implementing as a simple way to not have to manually define paths all over their applications - creating autoloaders. His post shows how to create one such autoloader for a legacy, non-framework type of project.
The first argument usually is "ease of use". It can get pretty annoying when you have to clutter your whole application with "require this file here and that file over there" statements. [...] The main motivation for autoloading usually is "getting rid of all the require statements and the problems resulting from forgetting one at one point where you don't notice it because on your machine it worked.
In some projects you're lucky enough to have class name to file name mapping to make it simpler. His project didn't have that, so he needed a way around it. His answer came in the PHP Autoload Builder tool - a handy command line script that works through your code and builds an index of sorts you can refer to for the correct class-to-file map.
voice your opinion now!
autoloader classmap phpautoloadbuilder tutorial
Rafael Dohms' Blog: SPL a hidden gem
by Chris Cornutt June 10, 2009 @ 11:19:06
Earlier this month Rafael Dohms posted a new article to his blog looking at a feature of PHP it seems not every developer knows about - the Standard PHP Library (or SPL).
By a show of hands, how many people here ever heard of SPL? How many already used it? Chances are most of you didn't raise your hands, and some might even have a confused look on their faces. Indeed that is the sad reality when it comes to SPL, but What is SPL?
He goes on to look at a few different things the SPL has to offer like autoloader overloading, iterators (with an included list of 21 of them) and the SplFixedArray that can be used to help speed up array access and manipulation.
voice your opinion now!
splfixedarray autoloader iterator spl
PHPRiot.com: Zend Framework 101 Zend_Loader
by Chris Cornutt March 12, 2009 @ 08:44:13
PHPRiot has started up a new series looking to introduce you to the Zend Framework one piece at a time. In this first article n the series Quentin Zervaas looks at one of the first components any Zend Framework-based application hits - Zend_Loader.
In this article I will introduce you to Zend_Loader, a Zend Framework class used to automatically load other classes. Typically you would use include_once() or require_once() when you want to load a class but using Zend_Loader you don't have to.
He talks some about how it works, how to enable an disable it and how you can replace it with your own custom autoloader if you want. He gives an example of doing this, overriding the loader with a call to registerAutoload to register his autoloader class.
voice your opinion now!
zendframework autoloader zendloader component tutorial
|
Community Events
Don't see your event here? Let us know!
|