 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
SaniSoft Blog: The prefix automagic in CakePHP routing
by Chris Cornutt April 09, 2008 @ 13:06:18
On the SaniSoft blog, Tarique Sani talks briefly about some of the prefix "automagic" that's already built in to the CakePHP framework's routing.
There are times when you need more than just admin routing, how about something like http://blah.com/user/profiles/edit and http://blah.com/user/profiles/changepassword ? If this could be routed to an action like user_add and user_changepassword wouldn't it be great!! (eg: think ownership ACL checks)
Good thing the CakePHP developers already planned for something like this - they included the connect() method for Router objects that maps the URL request to a method with that same prefix in the controller.
voice your opinion now!
cakephp framework prefix routing magic connect
Lars Strojny's Blog: New magic constant in PHP 5.3
by Chris Cornutt February 22, 2008 @ 15:02:00
In this new blog post today, Lars Strojny talks about a new magic constant that will be joining its brothers in the upcoming PHP 5.3 release - __DIR__.
In PHP 5.3 there will be another magic constant __DIR__. [...] To allow this, the internal function php_dirname() has been moved in the Zend Engine and is now called zend_dirname(). Nevertheless an alias still exists.
__DIR__ will join the other constants (like __LINE__ and __FUNCTION__) to help give the currently running script a little introspection for things like its filename, what class it's currently in and now, what directory the file currently lives in.
voice your opinion now!
dir magic constant directory php5 new
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
Chris Cassell's Blog: Creating Magic Methods in PHP
by Chris Cornutt August 13, 2007 @ 10:21:00
In this new entry to his blog today, Chris Cassell shows how to create "magic methods" - ones that make use of overloading to do special things.
I've learned a lot of things from various open source frameworks, especially CakePHP. One of the most impressive things about Cake, and Ruby on Rails for that matter, is its magic methods in its data model class [...] I've implemented similar methods in the home-grown framework that I use at work. Here's how to do it.
In his example, he gives both the PHP4 and PHP5 code to make a simple magic method class with a __call() function to handle undefined method calls. Using this, he maps a undefined method call to another method in the class (called findAllByColor and mapped to findAll with the right parameters).
voice your opinion now!
tutorial magic method class php5 php4 cakephp framework tutorial magic method class php5 php4 cakephp framework
WebReference.com: The Building Blocks Data Types, Literals, Variables, and Constants - Part 3
by Chris Cornutt January 29, 2007 @ 11:44:00
WebReference.com has posted part three of their "Building Blocks" series - a look at data types, literals, variables, and constants.
In part three, they focus more on the last type of "block" in their list - the constant:
Some real-world constants, such as pi, the speed of light, the number of inches in a foot, and the value of midnight, are values that don't change. PHP not only provides its own predefined constants but lets you create your own. Using constants makes it easy to write and maintain your programs.
There's talk of the define() and constant() functions and a mention of some of the predefined and "magic constants" as well.
voice your opinion now!
building blocks variable constant define magic building blocks variable constant define magic
php|architect: The Magic __set_state Method
by Chris Cornutt July 21, 2006 @ 07:03:00
On php|architect's A/R/T article repository today, there's this new tutorial centered around the use of the "magic" method __set_state in PHP5.
It is fairly self-evident how to use most of the magic methods of PHP 5. However, it is not quite so apparent how to use the __set_state method introduced in PHP 5.1. In this article, Peter lavin delves into this elusive magic method to show you how to use this gem in some really 'classy' object oriented PHP.
The author (Peter Lavin) talks first about what magic methods are and, specifically, what the __set_state method can do. He gives an example, comparing a normal usage of var_export to functionality using __set_state.
voice your opinion now!
magic method __set_state var_export tutorial magic method __set_state var_export tutorial
|
Community Events
Don't see your event here? Let us know!
|