When someone thinks of rapid web application development, Ruby on Rails is the framework everyone remembers first, but it has a problem. It does not run on standard LAMP web servers and so most web hosting services don't support it on their basic plan, which is the shared hosting. There are a few exceptions like Site5 however many complain of high loads and slow response. Alternative frameworks luckily exists though.

Symfony is a similar open-source PHP web framework but only requires PHP5. Many shared hosts provide PHP5 support very cheap, like GoDaddy, especially with coupons code from RetailMeNot. One can easily get the standalone sandbox available at the site, upload it to the web host and begin playing from there, without having to install a library since only Pear is needed and it is widely available. On the following sections I'll show the process of programming a basic blog+gallery, which you can see here, in about 24 hours. Just keep in mind I have very little PHP experience and never used Symfony before.

  • The Process

Symfony is very well documented, with tutorials, screencasts and even a real-world web app with step by step instructions. And so I began by reading the “my first project” tutorial and it was a great way to quickly get acquainted with the framework and its structure. Having had a good first impression, I decided to do a full install through Pear but then I got my first problem: not enough memory. After some quick googling, I found the error to be a low limit in php.ini and raised it.

Even though there are many tutorials available, I prefer to get by just with the API reference and the Symfony book. After a few minutes of reading, I started creating a new project and initial modules. Once again I had an unexpected little problem, after firing up my web server, I couldn't access any page. With the help of the development frontend, I found the error to be permission related because apache couldn't write to the cache directory, and so some tweaking was necessary.

Initial screenInitial blog module

I had a pure HTML and CSS version of the site done before of this project and so building this dynamic version wasn't as difficult as building something from scratch. After cleaning up one page, it was used as the template, and suddenly it looked like some good progress was made.

Template applied

Next step was using the admin generator which creates simple pages to list, create, edit and delete the various entries in the database. Nothing much really, but it is a nice base to build upon later. The modules which I created were Article, Comment, Wallpaper and Author.

Backend screenBackend author list

With some basic articles and wallpapers created in the DB, I began creating the main app modules: blog, gallery and comment. Once again, having used the CRUD generator (scaffolding), I had a base to work on and it was only necessary to do a little customization.

Testing the blog moduleTesting the gallery module

The final step of the implementation was the front page. At first I thought that I needed to create another module that would list all articles and wallpapers. It turns that there is a much better way which is to customize the default module to include components from other modules. This keeps the application modular and much cleaner since the logic relative to a module is kept inside the module.

Testing the final main page

Setting up the site on my shared host (GoDaddy) was easily done, thanks to this post. Basically, I just had to copy Symfony libraries to the web host and setup the rewrite rules. But there was a problem: all links would begin with “/web/” and internal files could be seen. This is because it isn't possible to point the document root to the “web” directory, in my case. Feeling adventurous, I started tinkering with the code and managed to patch it so that the “/web/” part would be dropped.

  • The Results

The end result is, of course, this site. As of this writing, stable Symfony version 0.6.3 is being used, but a beta for version 1.0 is already available. I plan to upgrade it soon but even this old version is very satisfactory. Templates, scaffolding, actions and helpers all worked together to speed up development and only a few lines of code (less than a hundred) were needed. My site is far from complete if you compare it with WordPress, for example, but for its purposes it's pretty good already.

I did ran into some problems like a fill-in bug when using XHTML and uploading a site through FTP can be very boring since Symphony only supports RSYNC. Authentication support isn't that great either, in my opinion, with you having to do some manual checks if some more complex authentication is needed. But overall, Symphony proved to be a very decent framework for the ruby-impaired, with quick learning and setup time.

—Ratow

On 15 December 2007 23:36:32 MST, Idetrorce wrote:

very interesting, but I don't agree with you Idetrorce

On 15 January 2008 17:22:34 MST, addendelm wrote:

Make peace, not war!

Add a Comment

Author:

Website:

Comment: