Archive for the ‘PHP’ Category

Zend Framework + Doctrine + ExtJS

Tuesday, January 5th, 2010

I started working on a new project today, which I hope to write about as I work through the different parts and challenges presented. I’m developing the project in PHP using Zend Framework with Doctrine ORM for the database layer. I’ve used ZF for a few projects now and it just keeps getting better and more mature. I’ve been reading about Doctrine ORM and read a few articles about integrating it with ZF and so far it’s been really good, although I’ve just barely scratched the surface.

The frontend of the project is going to just use the Zend Application MVC tool, but for the backend I’m using ExtJS. I’ve been a fan of ExtJS and used it for a few projects now but this time I’m trying something new – I’m using Zend_Json_Server to provide the data directly to ExtJS. I’m still working out how it works, but basically you create the objects on the backend, enable Zend_Json_Server and then your objects and methods are available right within the Ext.Direct and Ext.DataStore objects. Very slick. Once I’ve figured it out more I’ll post some links to the resources that helped me the most.

Also, it seems that everytime I log into WP there is a software update… maybe I need to post more.

PHP Frameworks Review

Thursday, September 10th, 2009

Over the last couple of weeks I’ve been able to work on projects using Zend Framework, CakePHP, and CodeIgniter. These are just a few of my own thoughts on the different frameworks.

CakePHP

Not a huge fan. My understanding is that CakePHP spawned from a desire to replicate the Ruby on Rails movement in PHP. My experience though is that it is slow and poorly documented. They try to get you to do things their way and I’m just not a big fan of that. I can understand trying to standardize for the sake of rapid development, but then you are stuck with development methods which work for small scale projects and not large complicated ones.

Zend Framework

This is the framework I’ve had the most experience. It’s got great documentation and a very active community. It does have the biggest learning curve though. While it’s true that ZF was more of a library in the past, they’ve made great strides to provide an application framework and a pretty decent one at that. It’s flexible and extensible. You can quickly whip up a small project and the system is adaptable enough that you can also build out large scalable projects.

CodeIgniter

CI is a great choice for those who don’t want to deal with the learning curve of ZF. It’s fast, well documented and has a great development community. It’s supported by a great company who has done a great job developing and promoting the framework. After working with CakePHP it felt refreshing to work with CI. Things were cleaner, faster, and just made more sense to me.

Summary

You can probably tell that I’m not a CakePHP fan. If I hadn’t picked up ZF for a few projects earlier in the year I probably would use CodeIgniter for everything. It’s still a bit of a toss up.

Working With Legacy Code – magic_quotes_gpc

Tuesday, July 14th, 2009

Sometimes you have to work with legacy code and you don’t have the budget to refactor it to remove practices that are deprecated. magic_quotes_gpc was a setting that was turned on for a lot of PHP 4 installations but it is now no longer a best practice to have it on. If you aren’t sure what that is, it automatically adds slashes or quotes data that comes in to PHP via cookies or a GET or POST HTTP request.

The PHP website has a good method of stripping out those slashes if you are unable to turn off magic_quotes_gpc (http://ca3.php.net/manual/en/security.magicquotes.disabling.php). But what if you need it on to run your legacy code? Here is the inverse of the solution that is provided on the PHP website:

if (!get_magic_quotes_gpc()) {
	function addslashes_deep($value)
	{
		$value = is_array($value) ?
		array_map('addslashes_deep', $value) :
		addslashes($value);
		return $value;
	}

	$_POST = array_map('addslashes_deep', $_POST);
	$_GET = array_map('addslashes_deep', $_GET);
	$_COOKIE = array_map('addslashes_deep', $_COOKIE);
	$_REQUEST = array_map('addslashes_deep', $_REQUEST);
}

Put that at the beginning of your script and it will add all of the slashes back in. Not ideal, but if you have no other option it will get you going again.