Kohana & FastCGI routing problems

If you’re developing on Kohana framework and your server is setup with Apache and FastCGI, you’ll run into some weird trouble regarding URL processing. This is happening because Kohana’s Router class is not looking at the REQUEST_URI key in the $_SERVER global, and gets the PHP_SELF...

Listing files in a directory with PHP

Listing the files in a directory in PHP is as simple as 1 line: $aList = scandir( '/tmp' ); print_r( $aList ); This will retrieve all the files in the specified directory (including “.” and “..”): Array ( [0] => . [1] => .. ...

Why should we use PHP constants inside classes

Why should we use PHP constants inside classes
constant A constant is an identifier (name) for a simple value. As the name suggests, that value cannot change during the execution of the script (except for magic constants, which aren’t actually constants). A constant is case-sensitive by default. By convention, constant identifiers are always...

CodeIgniter 1.6 + Rapyd library download

CodeIgniter 1.6 + Rapyd library download
When I need to develop a fast-growing, flexible and complex management application that needs to be done in a very short time, I use a CodeIgniter - Rapyd “bundle” that I’ve built to work, which can be turned into a really complex application. Actually, I’ve built a complex management...

APC - Alternative PHP Cache

APC - Alternative PHP Cache
APC is a simple and yet powerful PHP extension that does just that: caching. What for? Suppose you would have some piece of code that fetches some data from a table, and since you don’t use JOIN because you loose scalability, you’ll have to do some more SELECTs, and then format each row to...

How to setup Eclipse + XAMPP + Zend Optimizer + Debugging

How to setup Eclipse + XAMPP + Zend Optimizer + Debugging
[ This is currently a draft. will format and finish later ] Eclipse all-in-one here: Zend debugger here: http://downloads.zend.com/pdt/server-debugger/ How to allow Zend Debugger and Zend Optimizer to co-exist: http://blog.tigeryao.com/2008/how-to-allow-zend-optimizer-and-zend-debugger-coexist.html XAMPP...

XML2Array

XML2Array
I’ve seen here the shortest xml2array implementation: function xml2array($xml) { $xmlary = array(); $reels = '/<(\w+)\s*([^\/>]*)\s*(?:\/>|>(.*)<\/\s*\\1\s*>)/s’; $reattrs = ‘/(\w+)=(?:”|\’)([^"\']*)(:?”|\’)/’; preg_match_all($reels, $xml,...

PHP file operations on large files fail

PHP file operations on large files fail
If you have a 2.7 GB file, file_exists(’./filename’) works but is_file( ‘./filename’ ); fails gracefully. Not even Apache handles these kind of files very well so take care.

Linux I/O Redirection

Redirecting the output is useful everywhere, including in php. By using `exec()` to import a .sql file into mysql, everything goes smoothly. Until you get some errors. Mysql sends the errors it encounters to stderr instead of stdout. So… you get the command status 1 (something went bad), but no...

PHP5 Singleton pattern

class Singleton { static private $instance = NULL; private function __construct() { } static public function getInstance() { if (self::$instance == NULL) { self::$instance = new Singleton(); } return self::$instance; }} (source: http://devzone.zend.com/node/view/id/1714)

« Previous Entries