RSS - Latest posts Posts Tagged ‘tip’

Home » Tags » tip
25Dec
2010

Zend Application Resource Plugin Loading Issues

Admittedly thinking while feeling feverish is slightly impaired, but it took me a little while to figure this one out… Trying to integrate ZF 1.11 with Doctrine2 to as per this article, I was trying to be a smart-ass and use TS_Resource_EntityManager instead of the ugly looking TS_Resource_Entitymanager.

Unfortunately all this got me was this very unhelpful error:

Zend_Application_Bootstrap_Exception with message Resource
matching "entityManager" not found

It turns out that although the case of the resource name in the application.ini dosn’t really matter the class name does not like mixed case. So had to settle with TS_Resource_Entitymanager as the plugin name.

Categories:

15Dec
2010

Installing Windows 7 Guest on VMWare 7 on OpenSuse 11.3 Host

Maybe this will help anyone else stuck on the installation.

For a long while my Windows 7 install inside VMWare 7 would get stuck at “expanding files 0%”. I kept thinking it was my machine and setup that was causing issue, after all a x64 tablet pc is not your most common config. Just in case anyone is curious I’ve got a Thinkpad x201t.

After trying both 32bit and 64bit Windows 7 version, upgrading my RAM from 4GB to 8GB and trying out changing the virtual disk location from ntfs to ext3 and back I was quickly running out of options.

Unfortunately VMWare support is extremely picky about your os versions and didn’t even try to suggest anything unless I downgraded to OpenSuse 11.2 – which was not an option due to certain driver compatibility.

Fortunately I decided to give it one more go and instead of using my external dvd drive for the Windows 7 installation I saved the DVD as iso and run the installation that way. And there you go, that was the solution!

My suspicion was the fact that my DVD drive is usb powered, however while looking for a solution I saw similar questions being asked for other linux hosts and no mention of external DVD drives, so it might be a more generic issue.

Categories:

9Dec
2010

PHP_AUTH_USER and PHP_AUTH_PW is null

Ok, so you’re trying to setup password protection on your website using HTTP authentication. Unfortunately despite the request for password working your authentication keeps failing. If you check the output of your script and the password and username variables are not populated as expected it will usually be for one of two reasons.

Working code example


$username = "expectedUsername";
$password = "expectedPassword";

if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != $username || $_SERVER['PHP_AUTH_PW'] != $password) {
  header('WWW-Authenticate: Basic realm=""');
  header('HTTP/1.0 401 Unauthorized');
  echo '>h2>Authorization failed.>/h2>';
  exit;
} else if($_SERVER['PHP_AUTH_USER'] != $username & $_SERVER['PHP_AUTH_PW'] != $password){
  echo '>h2>Authorization failed.>/h2>';
  exit;
}

Most common reason for failure

Firstly if you are using an older book or website as reference you will see $PHP_AUTH_USER mentioned instead of $_SERVER['PHP_AUTH_USER']. If you are using the former then this could be the reason for not seeing your variables populated.

The reason that can take you by surprise

If your code is correct (compare against the example) and you are using the $_SERVER variable format and still getting NULL inside both $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] it’s time to check your server settings.

HTTP authentication does not work with the cgi version of PHP, so if your hosting allows you will need to switch to PHP as Apache module or look for an alternative solution.

Categories:

6Mar
2010

Multiple changes and a delete on same object in doctrine

If you want to make several different changes to a doctrine record object you might find yourself slightly puzzled when it comes to deleting related objects.

$user['Address']->delete();
$user['Address']->state(Doctrine_Record::STATE_LOCKED);
(...)
$user->save();

It seems that unless you set the state the save later on still sees an initialized (though empty!) relation.

Categories:

16Dec
2009

Zend_Date time part and GMT

If you live in the UK you might have a surprise waiting in store for you if you use Zend_Date for the time part only. For a while I even thought this was a bug, however digging deeper has shown that actually it’s Zend_Date that is right, in a way at least.

When setting a time before 1972 – this is 1970 and 1971 the time part will not be shifted in the UK locale as DST was only introduced in 1972!

This means if you are only calculating times and need the appropriate time adjustment you will need to set a date as no date part in Zend_Date means 1st Jan 1970.

Categories: