Nginx Configuration for Symfony

Recently when setting up a Symfony project on an Nginx powered server I found the Example configuration script found on the Nginx wiki for Symfony didn’t fully work as expected.

  1. If you added a slash to the end of the url when requesting backend.php or frontend_dev.php or similar caused the page not be found, even though under Apache this works fine and goes to the correct place. Which seemed to be caused by the script_name server param.
  2. GET parameters were not getting passed to Symfony. Caused by the arguments been removed during the try_files request.

So I modified the example config to produce the following, which as far as I can tell works exactly the same as the default .htaccess file does under Apache.

Continue reading

Using a non-integer primary key with Symfony’s Admin Generator

When Symfony creates an Admin module automatically its default routing setup only allows it to work with an integer based primary key. This means you can’t use a unique varchar column as your primary key, for example. There is however an easy way to solve this and tell Symfony to match other characters in its routing module. All you need to do is update your routing.yml file adding the requirements parameter like so:

user_languages:
 class: sfPropelRouteCollection    
 options:
   model:                user_languages
   module:               user_languages
   prefix_path:          /languages
   column:               iso
   with_wildcard_routes: true
 requirements:  { id: "[a-zA-Z]+" }

The above pattern will match any number of characters, and won’t worry about the case. However you could make this pattern match anything you wanted, the string must be a valid regular expression pattern the same as you would use for preg_match and similar.

Update to sdInteractiveChartPlugin for Symfony PHP

sdInteractiveChartPlugin has been updated to version to 0.3 to fix two little issues:

  • Symfonys sfOutputEscaperArrayDecorator objects can now be passed directly to the charting plugin and it will correctly format the values from the object.
  • Added support for automatically loading the Javascript files over https if the page request is over SSL.

More info and the download for the plugin can be found here:

http://www.symfony-project.org/plugins/sdInteractiveChartPlugin/0_3_0

A Symfony Plugin for Generating Charts using Googles Visualization API (sdInteractiveChartPlugin)

Last week I released the first (beta) version of my interactive charting plugin for the Symfony PHP framework. It is currently only version 0.1.2 so it’s a bit rusty round the edges, but over the next couple of weeks I will be improving it and adding extra functionality to it. I also intend to package up another version (which I will host on my blog) for anyone not using Symfony to use in there PHP projects. Below are just a few details on the plugin:

UPDATE: The plugin has been updated to version 0.2.0 (Available on the Symfony website), more of the APIs options have been implemented along with an improved callback function and more streamlined code.

Overview:

The plugin allows you to insert Javascript powered charts into any page of your site without writing any Javascript. It is especially useful when the data for the chart and possibly even the type of chart is based upon an authenticated users preferences (i.e. creating different charts for each user). The plugin handles the loading of the required libraries and creation of the correct chart object as well loading the data in via AJAX if you want. It also helps to keep your HTML page code as neat and tidy as possible by only writing exactly what’s needed into the dynamic page and storing all the rest in a general JS file which is the same for all users.

Chart Types:

It can create a number of different charts:

  • Area Charts
  • Bar Charts
  • Column Charts
  • Gauges
  • Line Graphs
  • Pie Charts

Usage:

Head to: http://www.symfony-project.org/plugins/sdInteractiveChartPlugin