When creating a link in a view file to another page of your application, Zend Framework provides a view helper that is very handy: Zend_View_Helper_Url.
'module' => 'abc',
'controller' => 'def',
'action' => 'ghi',
'param1' => '1',
'param2' => '2'
); // output: "/abc/def/ghi/param1/1/param2/2"
If you don’t provide the module, controller or action, the current module, controller or action will be used as default values.
I think this is a very easy way to create links inside an application, without retyping every time your controllers or actions.
Thanks to Ausy/Dataflow I will be present on Belgium’s most important PHP event of the year.
The 2010 event was great, and I was very happy I could be there. The schedule for this year looks very interesting too: tutorial on quality assurance and unit testing, RESTful web services, Doctrine, and ZF2.0. Those are already some of the talks I will attend.
All information can be found at conference.phpbenelux.eu
Already many thanks to the organizing crew! Hope to see you there!
My colleague Ward Loockx is starting a new business “E-volutions” in webhosting, domain names, and the most important part: free webshop hosting.
Go find out more about his products on www.e-volutions.be
If you are interested in the free webshop hosting, subscribe for more information on www.e-volutions.be/gratis-webshop
Today I passed the Zend Framework certification. From now on I can call myself Zend Framework Certified Engineer.
I followed the Zend Certification training at Ausy/Dataflow. Gauthier Delamarre is an excellent teacher, and he helped me very good to prepare for the examination. Though it is my opinion that with only the training you cannot pass. It requires a lot of experience with the ZF, and you have to study the online reference guide really good.
Some tips for anybody who wants to do the certification:
- know the output of every function,
- know which and how many parameters every function requires, but also know the optional parameters,
- know what happens if something goes wrong (does ZF throw an Exception or do you get a Fatal Error, a warning,…),
- know the configuration settings (for example Frontend and Backend Caching have a lot of settings),
- study the reference guide in depth!
A tip for all PHP developers using Eclipse PDT:
if you want to type a class name, for example “Zend_Controller_Request_Http”, you can just type “ZCRH“, and the Eclipse code assist will suggest “Zend_Controller_Request_Http”.
This works also in Zend Studio for Eclipse.
In my previous post I talked about query profiling in Firebug with FirePHP. Today I will talk about another feature from the Zend Framework and FirePHP: logging.
Again, it’s very simple:
- create a new Zend_Log
- add the Zend_Log_Writer_Firebug to it
$log = new Zend_Log();
This will behave like var_dump(), with these differences/improvements:
- the output is displayed in Firebug
- the HTML output doesn’t change
- also for Ajax calls; no var_dump() info visible in the output from the Ajax call
- the output has a nice layout
Remark: to use this, you need Firebug and FirePHP
Firebug gets better and better!
One of my last discoveries is Zend_Db_Profiler_Firebug. With this great feature of the Zend Framework it is possible to check queries in Firebug.
Step 1: install Firebug + FirePHP and activate the Console and Net tab
Step 2: activate Zend_Db_Profiler_Firebug in the application:
resources.db.params.profiler.class = Zend_Db_Profiler_Firebug
resources.db.params.profiler.enabled = true
For example enable it in development environment, and disable it in production.
Step 3: refresh your application, and see the queries appear in Firebug: you see the duration of all queries, and for each query individually, all parameters passed to the query and the total number of queries.
If you don’t want to use MySQL Proxy, this is a good alternative to check queries!
I have no hard data to prove it, but I don’t have the impression that it slows down my applications.
Does anybody know more about the performance of Profiler_Firebug?
The first step, encoding, was very easy. I used “gzencode()” and everything worked fine. Then I wanted to use the decoding function “gzdecode()” and I got this message “Fatal error: Call to undefined function phpdecode() “.
I go back to php.net, and there I see that the function gzdecode is documented, and no specifications are given which PHP version is needed, which extra extensions need to be installed etc. And since gzencode works fine, gzdecode should work fin too, isn’t it?
I google a little, and I find very little information. The best thing I see is this, on bugs.php.net. This issue is closed since 2006, and has one comment: “Implemented for PHP-6”.
So, why is gzencode() available in PHP5, en gzdecode() only in PHP6?
And because PHP6 is not out yet, what is the best solution: use other function (gzcompress() and gzdecompress(), gzinflate() and gzdeflate()), or use one of the meny alternative gzdecode() functions that user on php.net have written?
Congratulations to my colleague Ward Loockx for passing the PHP5 certification!
partial() will render a view script, and render() will render a view script. So… which one do I have to use?
All depends on the variable scope.
The render() function will render the given view script within the variable scope of the script is was called from.
partial() will also render the given view script, but you can define a special variable scope: you can pass all requested parameters in an array.
$this->partial('script.phtml', array('var1' => 'value 1', 'var2' => 'value 2'));
This can be very useful to use a view script in a loop.