 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Stubbles Blog: Extending objects with new methods at runtime
by Chris Cornutt September 01, 2009 @ 09:05:46
On the Stubbles blog today Frank Kleine looks at a cool trick that the features of PHP 5.3 now make possible - extending objects at runtime by adding in new methods and functionality.
With the advent of PHP 5.3 adding new methods to an instance of a class at runtime becomes possible with PHP as well, using anonymous functions and a little bit of __call() magic.
He illustrates with a bit of code - defining the base class and using a __call method to catch any undefined method calls. Using this in conjunction with closures makes it possible to call the method internally, avoiding the usual error that could result from setting it like you would a class property.
voice your opinion now!
extend object closure call
DevShed: The Call Magic Function in PHP 5
by Chris Cornutt June 09, 2009 @ 08:44:57
Continuing their look at the "magic functions" that are included in PHP5, DevShed has posted this new tutorial looking at the "__call" method to intercept calls to methods in a class that don't exist.
If you're a PHP developer who wishes to learn how to implement and use the set of magic functions that come included with PHP 5, you've come to the right place. [...] As the title of this article suggests, in the new few lines I'm going to take a deeper look at the"__call()" function, so that you can quickly become familiar with it.
They include code examples of the __call method in use - catching a call to a "fetch" method.
voice your opinion now!
tutorial call function magic
DevShed: Using the Xdebug Extension's xdebug_call_function() Function
by Chris Cornutt February 09, 2009 @ 12:56:18
This new tutorial from DevShed takes a look at the XDebug debugging tool for PHP and how the xdebug_call_function method allows for even more flexibility in your testing experience.
The Xdebug extension comes equipped with many other functions, however, that allow you to debug PHP applications more deeply. Therefore, in this second article of the series, I'll be discussing how to use another useful function included with the extension, called "xdebug_call_function()," which as its name suggests, can be utilized for keeping track of the functions called by a PHP script.
They start with a look back at two of the other xdebug functions - xdebug_call_file and xdebug_call_line - before showing how to use this new function (xdebug_call_function) to get the function that called your custom handler.
voice your opinion now!
xdebug call function file line debugger extension
Ibuildings Blog: Zend Framework testing emulating HTTP calls
by Chris Cornutt August 29, 2008 @ 15:26:55
On the Ibuildings blog today Lorenzo Alberton takes a look at the Zend Framework, specifically as to how it can mimic regular HTTP calls with the built-in components.
One of the unit testing best practices suggests to break dependencies, so you can test each component separately. The first problem that arises when you want to test controllers might be having a tighter control over the HTTP Request and Response objects.
This problem is overcome with the Zend_Test_PHPUnit_ControllerTestCase. The second problem it with calls to external resources (like models/databases or web services). This is the prime focus of the post and seceral blocks of code are included to make a class to emulate the HTTP responses you might get back from the service.
voice your opinion now!
zendframework testing http call webservice model unittest
Dhiraj Patra's Blog: Caching PHP Programs with PEAR
by Chris Cornutt August 07, 2008 @ 12:58:09
In a recent post to his blog Dhiraj Patra looks at the caching functionality that PEAR has to offer via the PEAR Cache package.
Caching is currently a hot topic in the PHP world. Because PHP produces dynamic web pages, scripts must be run and results must be calculated each time a web page is requested, regardless if the results are the same each time. In addition, PHP compiles the script every time it is requested. [...] PEAR's Cache package offers a framework for the caching of dynamic content, database queries, and PHP function calls.
He talks a bit about what kind of methods are included with the package and shows examples of how it works for function call caching, caching the output from the script execution and how to implement your own custom caching extension of the main code to make it even more flexible.
voice your opinion now!
pear cache tutorial function call output custom handler
Larry Garfield's Blog: Benchmarking magic
by Chris Cornutt November 08, 2007 @ 12:04:00
Larry Garfield has put together some benchmarks based around a request he had from other developers (the "performance czars") as to how the magic functions in PHP5 would perform in the new environment.
Already, there is talk of how, and if, to leverage PHP 5's object handling now that we don't need to deal with the weirdness of PHP 4's object model. Of course, because it's Drupal, our army of performance czars want to know just what the cost is for object handling, and especially advanced object magic like __get(), __call(), the ArrayAccess interface, and so forth.
He an his tests on a Thinkpad (Intel Core2 Duo 2.2Ghz) running Kubuntu and PHP 5.2.3. They were run two million times benchmarking the different methods for:
- function calls
- __call
- __get
- __set
- iterators (array)
- inheritance
- composition
His results are listed at the end of the post.
voice your opinion now!
benchmark magic function get set call iterator inheritance composition benchmark magic function get set call iterator inheritance composition
|
Community Events
Don't see your event here? Let us know!
|