Zend Framework Controller plugins are a powerful way to inject logic into your controller system at various points, such as before and after an action dispatch. Plugins are run in the order they are added, though it is possible to change the order by defining a custom stack index. ZF internal plugins such as Zend_Controller_Plugin_ErrorHandler, which displays a nice Error 404 page, has a stack index of 100 to ensure it runs near the end of any plugin cycle. However, it’s not so obvious from the ZF manual how to set a custom stack index.
Read the rest of this entry »
Understanding the stack index for Zend Framework Controller plugins
July 15th, 2010Finding the Apache user in PHP
October 27th, 2009In PHP, knowing what the Apache user is on your webserver is very useful. Anything that writes a file to the server for example sessions, uploading files or other temporary file operations, needs to have the destination folder writeable by Apache. If you’re developing locally that’s not usually a problem. But as soon as you’re out in the real world file permission issues can sometimes be a pain.
If you’re having difficulties finding out what the Apache user is try this simple script to help you out.
It basically writes a small temporary file, checks the owner username, gets rid of the file and prints the Apache username to the screen. It should work on PHP4 and PHP5.
$tmpFilename = tempnam('/tmp', 'TEST');
$handle = fopen($tmpFilename, 'w');
fwrite($handle, 'testdata');
fclose($handle);
$info = posix_getpwuid(fileowner($tmpFilename));
$apacheUser = $info['name'];
unlink($tmpFilename);
echo "The Apache user is $apacheUser";
There’s also a small PHP source file you can easily download and use: getApacheUser.phps
me
I run web agency Studio 24 and I blog occassionally about PHP, web standards, usability and general web development.
-
you are currently browsing the archives for the Quick tips category.
archives
categories
- Community (3)
- CSS (2)
- JavaScript (2)
- Misc (6)
- PHP (1)
- Quick tips (2)
- Web development (1)
- Web standards (1)
- Zend Framework (5)