Jul 29

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();
$log->addWriter(new Zend_Log_Writer_Firebug());
$log->debug($something);

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

FacebookDiggShare
Jul 23

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?

FacebookDiggShare
May 26

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?

FacebookDiggShare
Tags:
Apr 19

Congratulations to my colleague Ward Loockx for passing the PHP5 certification!

FacebookDiggShare
Tags:
Apr 16

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.

Render()

The render() function will render the given view script within the variable scope of the script is was called from.

$this->render('script.phtml');

Partial()

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.

FacebookDiggShare
Apr 14

My project is under version control with SVN. Although SVN is very usefull, it generates a lot of files, and sometimes this makes the performance bad.

Take for instance Zend_Translate. I use Qt to handle all translations. Qt will scan a given directory for all translation files, and so it will also scan all .svn directories.

resources.translate.data = APPLICATION_PATH "/locale"
resources.translate.adapter = Qt
resources.translate.options.scan = directory

While debugging my application, I discovered a very useful option to ignore all .svn directories:

resources.translate.options.ignore = ".svn"

Very useful option.
Off course it is possible to add more directories or files to ignore.

FacebookDiggShare
Apr 05

UPnP logoAfter 6 months, I got the UPnP network media streamer on my NAS (D-Link DNS-323) finally working.

The problem was that none of my media files was accessible on the network over UPnP. I could easily find the files with a file browser, but none of my UPnP clients detected any files.

Finally D-Link released a new firmware upgrade to version 1.08 with two fixes for the UPnP server:

  • UPnP AV can handle long file names and in file names with spaces
  • UPnP AV server will skip corrupted file instead of stopping the scan process

Now I can see where the problem was. Most of my media files have spaces in their names.

Good job for D-Link that it’s fixed now, but still a little too late…

FacebookDiggShare
Tags:
Mar 24

Logo Het Vlaamse KruisFrom September 2009 till March 2010 I followed a First Aid course from Het Vlaamse Kruis in Grimbergen. After 2 exams (one for the basic first aid, and one for advanced first aid), I received my diploma yesterday at the city hall of Grimbergen.

Thanks to all the volunteers for all their time in preparing the course! It was very interesting, and I had a lot of fun!

Edit: I found some articles from news websites:

FacebookDiggShare
Tags:
Mar 23

jQuery UI 1.8

Javascript Comments Off

I love to work with jQuery. It’s very easy to learn, and it’s so much fun to create applications, effects, Ajax, etc with it.

Next to jQuery, there is the jQuery UI. This user interface has not a lot of features like ExtJS, but the newest version (1.8) has already become a lot better.

The best new feature is the localization. In my last project it was a real struggle to implement the localization in French and Dutch, so I hope with the new version it will be again the jQuery style: smooth and easy.

jQuery UI also has a new widget: the long awaited Autocomplete. The only good solution I had for an autocomplete with jQuery was JAMES. I hop the new UI has an even better solution.

From the moment I can test all of this, I’ll write about my experiences!

FacebookDiggShare
Tags:
Mar 16

A few weeks ago I saw a very good ZendCast about Zend_Navigation.

This was a very good start for me to use Zend_Navigation for the menu and breadcrumbs in my application.

Performance

While developing there were some performance issues that came up:

  1. parsing a .ini or .xml file makes the application slower
  2. for Ajax-requests, the menu should not be loaded

The solution for the first problem is a simple array. I created a function getMenu() that returns a Zend_Navigation object, and this object contains my menu array. The array is less readable than a .ini or .xml file, I have to admin, but it’s still very easy to work with.

private function getMenu()
{
    return new Zend_Navigation(array(
        array(
            'label' => 'Home',
            'id' => 'home',
            'visible' => false,
            'controller' => 'index',
            'action' => 'index'
        ),
        array(
            'label' => 'Page 1',
            'id' => 'page_1',
            'uri' => '',
            'pages' => array(
                array(
                    'label' => 'Page 1.1',
                    'id' => 'page_1_1',
                    'controller' => 'general',
                    'action' => 'index'
                )
            )
        )
    ));
}

For the second problem I had to dig a little bit deeper into Zend Framework.
Normally the Zend_Layout and Zend_View are created in the bootstrap. And this is also the place where I would initialize Zend_Navigation.
For an Ajax request, I disable the layout.

$this->_helper->layout->disableLayout();
$this->getHelper('viewRenderer')->setNoRender();

Does it make sense to first create the layout and view, then add the menu to the view, and afterwards disable the layout if the application do an Ajax request?

My solution was this: I created a plugin for the menu. This plugin checks if the layout is enabled or disabled, and only creates the menu when the layout is enabled. The plugin uses the postDispatch method, because only then the layout can be checked if it is enabled or disabled. In the preDispatch it is always enabled.

public function postDispatch(Zend_Controller_Request_Abstract $request)
{
    $layout = Zend_Layout::getMVCInstance();
    $view = $layout->getView();
 
    if ($layout->isEnabled() && Zend_Auth::getInstance()->hasIdentity()) {
        $view->navigation($this->getMenu());
    }
}

Difference between URI and MVC

This is a very simple difference.

Zend_Navigation_Page_Mvc uses the parameters “controller” and “action” to create the anchors in the menu.
Zend_Navigation_Page_Uri uses the “uri” parameter the create the anchor.

I use only Mvc to create my anchors.
I use the Uri for one case: if I want a menu item that has no anchor. If the “uri” parameter is left blank, Zend_Navigation will display the label, but it will not create anchor tags around it, so you can create a nice menu with menu titles that are not linkable, and menu items with links underneath

FacebookDiggShare

© Filip Forrez, 2002 - 2012 | Powered by WordPress

preload preload preload