If you see the following error messages on the command line in windows, you know you going to be wasting an uncertain amount of time figuring out the right permissions for the directory D:\ZendFramework:
Warning: require_once(D:\ZendFramework\library\Zend\Loader\Autoloader): failed to open stream: Permission denied in D:\werk7\tiris\loadDocuments.php on line 15
Fatal error: require_once(): Failed opening required ‘Zend/Loader/Autoloader’ (include_path=’.;D:\ZendFramework\library’) in D:\werk7\tiris\loadDocuments.php on line 15
What is happening here? Let me tell you what I was trying to do. I was trying to execute a php script from the command line. Normally, this is a quite straightforward process. If you have properly installed php, there is nothing to it. Just type php file.php and php will happily execute the script contained within file.php.
Now what is happening in this case, is that Windows 7 is denying access to the ZendFramework directory, from which I am trying to include the file that contains the autoloader.
To you as seasoned developers, this may seem a pretty normal message. But please consider this message from a different perspective for once! What is happening is this: I, the owner of my laptop, is asking my application, php, to execute a script in my directory. And I am denied it and left with no clue on how to resolve the problem. I can only find a clue if I am willing to put myself in the position of a system administrator, which I consider to be a profession in its own right.
Ok, ok, I can here you all laugh from here. I should be able to administer a system that I own. But why is it so difficult? I made it a share, I allowed everyone into the directory etc. Still no luck. Then to think that all this time is just wasted. Completely wasted. This script will have to run on a different machine when it’s ready. So then, if finally I will have solved the permissions problem for my machine, I will have to repeat the steps for my clients machine… Yes, it might start all over again. Of course I googled for the solution, but permission problems are so wide-spread, it’s hard to find this specific situation. Who would use Windows 7 to run php in the first place?
So I looked into it again, and found that it did not work to give everyone permission to read/write (where is execute?), so I am trying that again. Because the directory contains so many files (thousands) it takes a huge amount of time to change the permissions, so I have plenty of time to blog about it while waiting. After waiting, it turns out it didn’t help to allow everyone to read/write to d:\ZendFramework. So what’s next?
The properties of the directory indicated that it is partly read-only (why? I did not ask for that). So I changed it to no longer be partly read-only, with no luck, it simply turns back to partly read-only (it is likely that svn is doing that in the background). I have to wait for another 45 seconds for that operation to complete. After that, the problem persists. I feel completely stupid, like a novice. No one would believe I have been developing for the web since 1995. And this is not even for the web, at least not directly.
Well then, you may think UAC is the problem (User Access Control) a feature in Windows since Vista. I must dissapoint you (and me), this is not the case. I immediately supected UAC to cause this, and started the console as Administrator. It made no difference…
php.exe itself may not have sufficient permissions… If I look at the properties of php.exe, there is a message that the program may be blocked, because it comes from another computer (??). There is a button next to this message, to unlock it. The unlocking works, but has no effect on the problem described here. See how many things one can try to waste ones’ time?
However it could still be UAC if I have to make php run as administrator to. There must be a command for that.
In The End:
As always, when you are wasting everybodies time, there was a typo. I was requiring the file Autoloader, while I should have been requiring Autoloader.php (note the extension!). So I was requiring a directory instead of a file (which is not possible and completely pointless). I do not know what made me suddenly notice the typo, these things happen. Time wasted: an hour at the very least. It would of course have been very friendly if the require_once statement would have thrown an exception or issued a warning telling that I was trying to include a directory. But you can’t expect everything.