Book Image

eZ Publish 4: Enterprise Web Sites Step-by-Step

Book Image

eZ Publish 4: Enterprise Web Sites Step-by-Step

Overview of this book

eZ Publish provides developers with a structure to build highly impressive applications and then quickly deploy them into a live environment. eZ Publish is complex, with a steep learning curve, but with the right direction it offers great flexibility and power. What makes eZ Publish special is not the long list of features, but what's going on behind the scenes. Created specifically for newcomers to eZ Publish, and using an example Magazine web site, this book focuses on designing, building and deploying eZ Publish to create an enterprise site quickly and easily. This tutorial takes eZ Publish's steep learning curve head-on, and walks you through the process of designing and building content-rich web sites. It makes the unrivalled power and flexibility of eZ Publish accessible to all developers. The book is organized around technical topics, which are handled in depth, with a general progression that follows the learning experience of the reader, and features a single magazine web site project from installation to completion and deployment. This hands-on guide helps the reader to understand the Content Management System to create a web 2.0-ready web site by creating new extensions or overriding the existing ones. In turn, it helps you to become confident when working in the eZ Publish administration area and offers an environment in which you can practice while working through the chapters.
Table of Contents (20 chapters)
eZ Publish 4: Enterprise Web Sites Step-by-Step
Credits
About the Authors
About the Reviewer
Preface
Advance Debugging

Appendix B. Advance Debugging

During the development of an eZ Publish site, it is very important to have immediate feedback about what we are doing. The CMF gives us a couple of debuggers to help us in our task. These are the code debugger and the template debugger.

Code debugger

eZ Publish includes a wrapper for all of the errors returned by PHP, which will display the errors at the bottom of our page, or in a new page if we prefer. When we release a site, it's very important that all of the errors are fixed, in order to avoid bad surprises or a slowdown of the application.

To use the debugging capabilities of the system, we have to edit the site.ini file of the global siteaccess, and enable the DebugOutput parameter.

[DebugSettings]
DebugOutput=enabled

After we enable this setting and empty the cache, we will see the debugger, as shown in the following screenshot:

On this page, we can see some utils that are used to clear the cache and enable different kinds of debug, such as the loading the .ini files, the execution of the queries, or the template rendering time.

Moreover, this parameter will enable some special operators for the template that will allow us to print the HTML output of the page, and the values of the variables used.

Debug template operators

The most important operators for debugging are debug-log, debug-timing-point, and debug-accumulator. These operators allow us to see particular information about how much time our code needs to run, and the values of the instantiated variables. We will look at the operators one by one.

Debug-log

This operator will perform a PHP var_dump of objects, arrays, and strings. This means that you'll be able to see what a particular object contains in the current page.

{debug-log var=$object msg='object contents'}
{debug-log msg='hello world'}
{debug-log var=array(1,2,3)}
Debug-timing-point

This particular operator will give us the ability to analyze the time needed to execute a certain block of code.

{debug-timing-point id=""}
{$item} - {$item2}
{/debug-timing-point}

As we can see in the above screenshot, you can truncate your code with some checkpoints to see which parts of your templates are the most time-consuming.

Debug-accumulator

The debug-accumulator template function executes the body and generates the statistics. The number of calls, total time, and average time will be shown in the debugger.

{debug-accumulator}
{section var=error loop=$errors}{$error}{/section}
{/debug-accumulator}

This operator is quite useful when we want to have a complete view of how complex the pages are and the resources that they need, such as MySQL query timing.

Templating debug

Using the debugger of the templating system, we should be able to know:

  • The list of the templates and sub-templates loaded into the displayed page

  • The number of these templates

  • The total number of loaded templates, if some templates are loaded more than once

To enable this debugger, as shown in the previous screenshot, we have to enable the debugOutput option, as seen before. Next, we have to enable the ShowUsedTemplates setting of the TemplateSettings, in the same site.ini file.

[TemplateSettings]
...
ShowUsedTemplates=enabled
...

Moreover, by enabling this kind of debug, we'll be able to edit the templates by clicking on the relative edit button. You can see this in the following screenshot:

Now, we can enable the verbose debugger output, by using the Debug parameter, and then render the inline of the name of the loaded template in the HTML page, by using the ShowXHTMLCode parameter.

[TemplateSettings]
...
Debug=enabled
ShowXHTMLCode=enabled
...

When ShowXHTMLCode is enabled, eZ publish will display a comment in the rendered output of the browser each time a new template is loaded, as shown in the previous screenshot.