Shared Know How


Howto: fix, find, use, make & do it guide

Archive for the ‘php’ Category

Optimize your PHP website performance

author Posted by: Tim on date Apr 16th, 2010 | filed Filed under: Other stuff, php, programming, webserver

Optimize your PHP website by making sure you use the following tricks

The list

Optimize front-end

  • Combine CSS files as much as possible
  • Combine Javascript files as much as possible
  • Always place a favicon.ico (saves needless 404 request and file searches)
  • If you use a lot of small images for your website make use of CSS Sprites
  • Use GZIP compression

Optimize PHP

  • Install APC (Alternative PHP Cache). This will speed your php up a lot
  • if you don't use .htaccess or have control over the server remove .htaccess ability and set any options in your apache virtual host file.
  • don't use current directory (".") in your include path but instead link directly to files in your code: include("./example.php")
  • Watch how many include paths you have. It will search in every folder for to find include file.
  • use persistent mysql connection (mysql_pconnect)

This list is based on the presentation of Rasmus Ledorf at Campus Party 2010 - http://talks.php.net/show/cp10. Out of this e've compiled a small checklist of things to do when you create a php website. This will make sure you will use all the simple tricks to make your website and PHP code to run fast. Further information on how to benchmark this look at the presentation of Rasmus.

Solved Dojo> Dijit.Dialog in ZendFrameWork doesn’t parse

author Posted by: Tim on date Jun 8th, 2009 | filed Filed under: php, programming

When trying to make a Dojo dialog work with another controller which is loaded trough the href attribute of the dialog. The content will not render as dijit elements.

This is because ZendFramework places all the properties in the Javascript array zendDijits and then add them to the elements after loading. However this will not work for the loaded Dialog because the ZendDijits are set in the view of the controller opening the dialog.

The simple solution to this is to use the declaritive formin the Zend_Dojo_View_Helper_Dojo by placing the following line in your code:

  1.  
  2. Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
  3.  

I placed this in my bootstrap.php right after the line where the Zend_Dojo_View_Helper is loaded.

Making de view helper declarative will place the dojo properties directly into the html of the elements.
Side-effect: the script will not be correctly verified as valid (x)html but it will solve the problem!