Friday 11 December 2009

Accessing the symfony development environment

No later than this morning was I trying to use my symfony dev environment from a different PC on the network, and came across the following error:

You are not allowed to access this file. Check xxxxx_dev.php for more information.

Well, to every simple problem it seems there is a simple solution :).

Just open xxxxx_dev.php and add the relevant IP address to the array as follows:


if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '192.168.254.102', '::1')))
{
die('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}


Obviously you probably wouldn't want to do this on a public server but it's neat for LAN use all the same and I am just literally more and more impressed with all the inbuilt mechanisms that symfony has to offer!

Thoughts?

Saturday 5 December 2009

JTable in JScrollPane showing default column names

Well, back to the basics of Java...

Just in case anybody (that's including me ;-)) gets this problem (again) here is the solution.

Basic scenario: building a JTable with a non default model class extending AbstractTableModel as follows. I have omitted necessary includes and actually removed method bodies for simplification purposes.

Spot the error...


public class SyncOperationTableModel extends AbstractTableModel
{
// attributes

public SyncOperationTableModel(ArrayList syncOperations)
{
super();
// initialize attributes
}

public int getRowCount()
{
// return the row count based on attributes (for instance)
}

public int getColumnCount()
{
// return column count base on attributes (for instance)
}

public String getColumName(int column)
{
// return column name
}

public Object getValueAt(int row, int column)
{
// return the value,
// by default setValueAt is not necessary
// (AbstractTableModel returns false to isCellEditable method)
}

}



Symptom? The column names (getColumName(int column)) never get returned and are replaced with default names: A, B, C... At first sight this is strange, since I purposefully add the table to a JScrollPane (which should handle the table header automatically).

Solution? In the above code the getColumnName(int column) does not get called simply because I have created a new method named getColumName (i.e. with a missing 'n' to the 'column' part of the name). Stu-pid!

New method:


@Override
public String getColumnName(int column)
{
// code
}


Reaaaaally hopeless... no wonder this was impossible to find despite GIYF. Now getting on to cell rendering - it's been a while... other silly mistakes ahead I am sure.

More news soon.

Thoughts in the meantime?

Tuesday 3 November 2009

Sunday 25 October 2009

10 reasons to use symfony

I have been thinking about the added value of using a good development framework and here are my top 10 benefits of using symfony as a development framework vs traditional program development. I won't be talking here about the license, which is open source MIT (which is great) but specifically of the programming and features aspects.

Rapid Application Development
Write better code faster. I know it sounds too good to be true but this is definitely the most obvious benefit of using a good application development framework.

Promote good code design and OOP
Using the inbuilt MVC makes the code easier to maintain and design. The symfony documentation is full of guidelines to make code easy to use during the course of the various development steps. Also, it's built on PHP5 and is fully object-oriented. This again promotes good code design and reusability.

Concentrate on the essential
When building a web application, you often find yourself doing the same things over and over again. OK, the table names change from one module to the next, as does the data structure but the logic behind managing objects is mostly the same. So, why waste precious time on the standard "common" code, when you could be spending it concentrating on the much more rewarding essentials: specific business logic, security, usability, ... since those are the things which in effect rake in the money and differenciate your product from the next?

Encourage proper code documentation
Because the framework handles most of what's happening behind the scenes, it becomes much easier to document code as you go along. And, symfony integrates phpdoc by default.

Provide different environments
Ever found yourself thinking "Gosh, I wish I could just switch to development for a second just to see the detailed error" or "I wonder how this will work in production?". Well, symfony provides inbuilt mechanisms which allow you to simply switch from one to the other, without ever disrupting the actual production environment. This also promotes testing and thus application stableness and scalibility.

Increase security
symfony provides mechanisms, tips and suggestions for output escaping, preventing SQL injection, and CSRF attacks. You really need to read the documentation from cover to cover to take full advantage of all the options provided by the framework, but it's a worthwile read!

Abstract from database
Using a database abstraction layer and ORM makes the process of accessing data completely transparent. You no longer have to worry about actually accessing the database to create, retrieve, update and delete data. All the internals are hidden. You just access the objects via the ORM layer that sits above the database abstraction layer and that's it. Did someone say KISS? :)

Manage credentials
Managing credentials is dead-easy as symfony provides a simple plugin that does all the nitty gritty behind-the-scenes work for you!

Internationalize and localize
I guess this is probably one of the most important issues, certainly for European customers. Again, symfony creators have made this one of their key features and internationalization and localization is made easy by in-built ready-to-use mechanisms.

Join a living community
symfony is big, and getting bigger. It seems everyone today will agree one of the major advantages of open source is the community that builds around the project and provides support, ideas and new features to an already growing project. Neat.

Well, those are the top 10 I could think of. Of course, there are many other things like a.o. integrated Javascript frameworks (scriptaculous...), various helpers and simplified AJAX development.

What benefits do you associate with using a development framework (or symfony more specifically)?

Wednesday 7 January 2009

Everything you know about CSS is wrong

Well, lots of people have been talking about this book.
You can read a chapter here.
And a review by Martin Heller here.

A big thumbs up for CSS tables, way to go! :)

Thoughts?

Monday 5 January 2009

Time to move on to SHA

Researches have 'broken' SSL! Ouch.
In the following ZDNet report there is some good news though: the hack is apparently very time-consuming.

Thoughts?
Online Marketing
Add blog to our blog directory blog search directory Blog Directory Blogarama - The Blog Directory