Sep 10 2009

Eclipse PDT and Zend Studio are really nice editors for general use. Once they’re set up the way you want, they work mostly fine. I have an issue where I type a dollar symbol ($) and the code assist goes off in a wobbly, probably due to the size of the projects we work on at Netbasic, and the fact that we’re all working off a network drive (ridiculous in my opinion…).

The biggest gripe I have with Eclipse however, is trying to install plug-ins. I don’t think I’ve EVER installed a plug-in without having to manually mess around with dependencies and trying to manually resolve them. It’s a HUGE downfall, and makes any Eclipse IDE virtually unusable. It’s intensely annoying when I just want to get on with things, but some bloody plug-in I need (normally the CollabNet/Mylyn plugins) just won’t install without getting in a hissy fit.

Take for example this latest error:

Cannot complete the install because of a conflicting dependency.
Software being installed: Mylyn Task List (Required) 3.2.0.v20090617-0100-e3x (org.eclipse.mylyn_feature.feature.group 3.2.0.v20090617-0100-e3x)
Software currently installed: Zend Studio 7.0.0.v20090806 (com.zend.php.ide 7.0.0.v20090806)
Only one of the following can be installed at once:
Java 5 Compatibility Checker 3.2.0.v20090617-0100-e3x (org.eclipse.mylyn.compatibility 3.2.0.v20090617-0100-e3x)
Java 5 Compatibility Checker 3.2.1.v20090722-0200-e3x (org.eclipse.mylyn.compatibility 3.2.1.v20090722-0200-e3x)
Cannot satisfy dependency:
From: Zend Studio 7.0.0.v20090806 (com.zend.php.ide 7.0.0.v20090806)
To: org.eclipse.mylyn.ide_feature.feature.group [3.2.1.v20090722-0200-e3x]
Cannot satisfy dependency:
From: Mylyn Task-Focused Interface (Recommended) 3.2.1.v20090722-0200-e3x (org.eclipse.mylyn.context_feature.feature.group 3.2.1.v20090722-0200-e3x)
To: org.eclipse.mylyn_feature.feature.group [3.2.1.v20090722-0200-e3x]
Cannot satisfy dependency:
From: Mylyn Bridge: Eclipse IDE 3.2.1.v20090722-0200-e3x (org.eclipse.mylyn.ide_feature.feature.group 3.2.1.v20090722-0200-e3x)
To: org.eclipse.mylyn.team_feature.feature.group [3.2.1.v20090722-0200-e3x]
Cannot satisfy dependency:
From: Mylyn Bridge: Team Support 3.2.1.v20090722-0200-e3x (org.eclipse.mylyn.team_feature.feature.group 3.2.1.v20090722-0200-e3x)
To: org.eclipse.mylyn.context_feature.feature.group [3.2.1.v20090722-0200-e3x]
Cannot satisfy dependency:
From: Mylyn Task List (Required) 3.2.0.v20090617-0100-e3x (org.eclipse.mylyn_feature.feature.group 3.2.0.v20090617-0100-e3x)
To: org.eclipse.mylyn.compatibility [3.2.0.v20090617-0100-e3x]
Cannot satisfy dependency:
From: Mylyn Task List (Required) 3.2.1.v20090722-0200-e3x (org.eclipse.mylyn_feature.feature.group 3.2.1.v20090722-0200-e3x)
To: org.eclipse.mylyn.compatibility [3.2.1.v20090722-0200-e3x]

From what I understand here, I can’t install Mylyn because of a 0.0.1 version difference. Because of two packages that were released within a month of each other?! That – in my opinion – is stupid. I just want to get on with things but I can’t because of this.

I sincerely hope the next version of Eclipse will sort out this stupid dependency issue, as if I was the Eclipse development team, this sort of difficulty-of-use issue would be a real show-stopper. In addition, I have no idea why Zend would base their €399 IDE which is meant to be a “professional-grade” solution to “maximise developer productivity” on such a shoddy, buggy IDE.

Aug 25 2009

zce-test2

As some of you may know, back in March/April time, I started revising for my Zend PHP5 Certification, but that was pretty much put on hold when we had a baby… now I’m revising again and after having revised a couple of topics I retook the test. As you can see, I passed it “with flying colours” this time, but still have improvement to do with Streams and Design patterns…

Comparing with my last test:

  • 2 categories remained the same;
    • Database access
    • Web features)
  • 4 categories improved;
    • PHP 4/5 Differences (was FAIL)
    • Security (was PASS)
    • String Manipulation and Regular Expressions (was PASS)
    • Functions (was PASS)
  • 2 categories declined;
    • Streams and Network Programming (was PASS)
    • Design (was EXCELLENT) [eep - not so good that!]

I think overall however, these statistics shouldn’t be examined too much – there are some questions I can guess and don’t demonstrate that I truly *know* some topics, so I’m going to cover off a few categories I don’t feel to confident on anyway – but then the practise tests are just indicators, and not meant to represent the final exam… we’ll see!

May 16 2009

As with everything I do, I hack together solutions when there’s probably a much better and easier way of doing things. But anyway – if there’s not an easier way, then here’s a solution to my problem, and if there is, well… I’ll just use that in future…

My problem is that I want pretty URLs for my app, such as http://blah.com/home/folder/5/item/27. The URL structure of Zend Framework means that the URL has to look like this: http://blah.com/home/index/folder/5/item/27. There’s probably a way around that (my original idea was to use http://blah.com/home/?folder=5&item=27 but that’s just ugly), but I’ll settle for using the pointless verb “go” as the action name, resulting in http://blah.com/home/go/folder/5/item/27. But I also want that goAction to be called when I just go to http://blah.com/home/. I had a quick look at the ZF documentation, but I couldn’t see much about setting a default action in a controller, so here’s my solution:

class HomeController extends Zend_Controller_Action
{
	public function indexAction()
	{
		// ... action code here ...
	}
 
	public function goAction()
	{
		$this->_forward('index');
	}
}

As I said, there’s probably an easier way around this, but this works for me, so ner!

Update: As always, there is an easier way of doing this and I was reading the wrong part of the documentation. As Patrick says in his comment:

Hello, there is a way to specify default module, controller and action for each active route in the Zend_Controller_Router used by Zend_Controller_Front.

http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.routes.standard.variable-defaults

just pass an array

Apr 10 2009

I’ve been getting to know Zend Framework, and despite it being awesome so far, there’s a few quirks I just don’t understand… maybe I missed something…

Anyway, David Cooper posted a quick howto on adding CSS to a Zend Framework page, which works and is all well and good, but there was a problem. The code that Zend Framework spits out was not XHTML valid. As I said, I might’ve missed something out, and this might be a really convoluted way of doing things, but give me a break, I’m just learning it!

Firstly, in your controller’s action (e.g. IndexController::indexAction), add a list of CSS files:

$css_files = array('index.css','test.css');
$this->getFrontController()->setParam('css',$css_files);

Modify the list of CSS files to suit your needs. Note that the $css_files must be an array, otherwise the helper class will ignore it. Now add a new PHP file in application/views/helpers called ‘CssInclude.php’, and put this in it:

<?php
 
class Zend_View_Helper_CssInclude
{
	function cssInclude()
	{
		$output = '';
		$fc = Zend_Controller_Front::getInstance();
		$baseUrl = $fc->getBaseUrl();
		$css_files = $fc->getParam('css');
 
		if(is_array($css_files))
		{
			foreach($css_files as $css_file)
			{
				$output .= '	<link rel="stylesheet" type="text/css" media="screen" href="';
				$output .= $baseUrl . '/css/' . $css_file . "\" />\n";
			}
		}
		return $output;
	}
}

This is a helper class that takes the parameter you set in the controller, and simply churns out an XHTML valid <link> tag. There’s just one more step, add this in your layout or view:

<?php echo $this->cssInclude(); ?>

And voila! If there’s a better way of doing this, then I’d like to know!

Apr 7 2009

UPDATE!!

For the new Zend Framework 1.8.x series, please refer to this article. This is still here for historical purposes.

This is a pretty simple howto, but here it is anyway!

I assume already that you’ve got a LAMP stack working, and if you don’t, it’s easy as pie to install one in Ubuntu:

sudo tasksel install lamp-server

So now you’ve got your LAMP stack up and running, lets download the latest SVN tag of Zend Framework. At the time of writing, the latest stable is 1.7.8, which I’ll use here. If you want to check for the latest version, visit http://framework.zend.com/svn/framework/standard/tags/ in your browser, and the last folder is the one you want. If you want stable full releases, ignore the RC/PR versions. So, once you’ve determined the version you want, we’ll check out the release:

cd /usr/share/php5
sudo mkdir ZendFramework
sudo svn co http://framework.zend.com/svn/framework/standard/tags/release-1.7.8/

It is likely you’ll need to use sudo for these commands as /usr/share/php5 is owned by root by default. You’ll see a big long list of files being checked out, and once that’s done you’ll have a new folder appropriately named “release-1.7.8″. Create a soft link called “current” to the release folder so you can change the default included Zend Framework version without restarting Apache in the future:

sudo ln -s release-1.7.8 current

You can stop there if you like, and manually add the include path into your PHP scripts using set_include_path. However, if you would like the current Zend Framework included automatically, then continue by opening /etc/php5/apache2/php.ini in your favourite editor. Add the path to your include_path list. For example, if your current include_path is (and this is the default):

include_path = ".:/usr/share/php5:/usr/share/pear"

Then change it to:

include_path = ".:/usr/share/php5:/usr/share/pear:/usr/share/php5/ZendFramework/current/library"

All you need to do now is restart Apache:

/etc/init.d/apache2 restart

In the future, if you wish to change to a new default Zend Framework version (for example 1.8.0), then just check out the SVN directory and change the soft link. You won’t even have to restart Apache, and the changes will take effect immediately! For example:

sudo svn co http://framework.zend.com/svn/framework/standard/tags/release-1.8.0/
sudo rm current
sudo ln -s release-1.8.0 current

If you want to keep up to date with the latest Zend software, then just subscribe to their RSS feed!