Php: page 4
How the ssdeep PHP extension came into being
Recently (well in a loose sense anyway) I had the need to build a document bank in PHP for a client at Mosaic. It was a fairly involved application with various public and private APIs for integration into the clients network of websites. The core PHP code was written on top of the Agavi framework and various PHP libraries for extracting text and meta data from documents. One of the major features the client required was for the system to detect similar files to prevent unintentional duplicates making it into the document bank. Read more ⇒
Gearman, PHP and mod_gearman_status on Ubuntu
Installing Gearman is pretty easy as there are packages for it in Ubuntu: sudo apt-get install gearman libgearman-dev The development headers (libgearman-dev) are only required if you need to compile a library for your programming language such as a PHP extension. To install the PHP module you would run: sudo pecl install channel://pecl.php.net/gearman-0.7.0 If you have trouble with the above step then it is probably because you are running an older version of Ubuntu. Read more ⇒
PHP Hangs When Fed 2.2250738585072011e-308
PHP Hangs When Fed 2.2250738585072011e-308 A pretty horrible bug when you assign the number 2.2250738585072011e-308 to a variable PHP will hang on Linux or Windows 32bit builds of PHP. This does affect $_GET and $_POST variables as well and as such could be an exploit in some PHP sites. So the following code will break your PHP for example: $var = 2.2250738585072011e-308; Or if a page is given a GET parameter like page. Read more ⇒
Logging global PHP objects and saving memory using a lazy loading proxy
Quite often when you are working with legacy code you will come across a mess of globals. Every single method will make use of the same global instance of the database class for example. So where do you begin to work with this massive impediment? Logging is a great way to see what methods and classes are being used by you application and where. To achieve this you would normally need to add a logging call to each and every method in the code base. Read more ⇒
An Excellent Development Server for a Team of Developers
Introduction When working in a team it is very useful to have a central web server with multiple environments and a configuration as close to the live server as possible. This can be a bit of a nightmare though if you need to setup a new VirtualHost container in Apache every time a new project is brought on or when a developer wants to work on a version of the site in their own environment. Read more ⇒
Installing via the pecl command can be a pain on Redhat. First off all you will need to install the php-devel package: yum install php-devel Then you will need ensure that the PEAR/PECL installer is at the latest version so as root run: pear channel-update pear.php.net pear upgrade pear You may need to force pear to upgrade itself by using: pear upgrade –force pear I had to use the –force option because my version of PEAR was so old that the installer thought my version of Tar_Archive might not have been up to muster. Read more ⇒
15 Excellent Resources for PHP Extension Development
Whilst developing a PHP extension recently I spent quite a bit of time researching exactly how to create an extension, the best practices and the DocBook format of the PHP manual for documenting the extension. By the time I finished writing the extension I had found some very good resources both on the web and in print. Printed books: Sara Golemon’s Extending and Embedding PHP Advanced PHP Programming by George Schlossnagle Building Custom PHP Extensions by Blake Schwendiman Online articles and presentations: The Internals section of the PHP manual Kristina Chodorow’s PHP Extensions Made Eldrich on her blog in 2011: Installing PHP Hello, World! Read more ⇒
The PHP ssdeep Extension is Now in PECL
The PHP ssdeep Extension is Now in PECL This means you can now install it easily by simply running: sudo pecl install ssdeep There is also proper documentation in the PHP manual which can be found at php.net/ssdeep. For more information on the extension either see the PECL project page or the ssdeep PHP/PECL extension’s homepage. Read more ⇒
php_ssdeep Fuzzy Hashing PHP Extension
php_ssdeep Fuzzy Hashing PHP Extension **Updated 16/9:**php_ssdeep is now in PECL so I have updated this post to reflect that. On a recent project I needed a fast way to compare documents for likeness and return a percentage match. With much research and one unanswered Stackoverflow post later I came across Jesse Kornblum’s ssdeep utility intended for computer forensics such as looking for signatures in files when hunting rootkits etc. All the technical details of fuzzy hashing are described in his 2006 journal article Identifying almost identical files using context triggered piecewise hashing. Read more ⇒
A PHP wrapper for the unix at command
A project I am working on at the moment requires time delayed job queues and having found nothing yet that can manage it properly so I decided to wrap up `at` into a PHP class. This gives you simple methods to add, list and remove jobs from the `at` queue using object oriented code. The code is very simple and I have documented it reasonably well so along with the examples you should get on your way quickly. Read more ⇒