UPDATE: I have changed the requirements from APD to Runkit OR APD instead. This gives you 2 options. If you use PHP 4 to 5.1 then using APD is the easier route but I dont have install instructions for that right now. If you use php 5.2 to 5.3 then you will need to use Runkit. I have not been able to get APD to work on anything greater than 5.1 yet so I've decided to include Runkit in the mix to cover all the PHP versions. Runkit does not have the ZendOptimizer compatibility problems that PECL APD has. It also works with php 5.2 and php 5.3 where as APD does not. But it is NOT without it's own problems. It's not really compilable from SVN/CVS nor it's own releases. It has to be patched before it'll even work, the project is a complete mess. So I've done this for you and included it.

Test Module
There is now a test module included in this. It showcases what you can do quickly to override/redefine drupal functions. It takes one of the most commonly used drupal functions "drupal_set_message" and completely overrides it with a NEW function. This new function works exactly like the original with 1 exception. It causes a javascript alert box to popup up everytime drupal_set_message() is called by ANY module. So this shows you that you can indeed modify drupal core functions WITHOUT modifying the core files themselves. It does this by using a new hook called hook_function_overrides() that the drupal_override_function module exposes. You can use this hook in your modules to override ANY function you want. But do NOT attempt to override PHP functions. It may "appear" to work, but you will notice random problems on the site. So dont go overriding something like print_r lol. Neither APD nor Runkit are stable enough to do that.

REQUIREMENTS:

  • PECL Runkit OR PECL APD

Whats the difference between Runkit and APD, which one should I use?
Lets start with the pros/cons of each one and then you decide which one you should be using.

APD CONS: has problems with PHP 5.2 and PHP 5.3. It will not compile with either of these and I've yet to find a patch to fix it. Also, APD is NOT compatible with ZendOptimizer. This is a very big problem because a lot of closed source apps use Zend. So you couldnt have APD and a Zend app reside on the same server.

APD PROS: APD is very easy to install IF it works on your server. It takes 1 line to install it and a couple edits to the php.ini file and you are done.

Runkit CONS: has problems with PHP 5.2 and PHP 5.3. It will not compile with either 5.2 nor 5.3 using the pear install commands but I have put together a version that WILL compile on these. So it's a viable option if you use PHP 5.2/5.3 (likely since a lot of modules are now forcing you to switch to 5.2 anyways.

Runkit PROS: Its more versatile than APD in the functions that it provides. Its also a lot easier to install on PHP 4.0 and PHP 5.1. Easier than APD. It also does not suffer from the ZendOptimizer compatibility problem. This makes it possible to use Zend apps as well on the same server.

So which one should you use? Answer is pretty simple. If in doubt, install Runkit whenever possible. Only install APD if you cannot get runkit to work.

Real world Requirements
If you have neither APD nor Runkit installed (Very likely you do NOT), you will also need the following:

For PECL APD:

  • SSH Root access
  • PEAR/PECL commands installed and working

For Runkit:

  • Root SSH Access - If you dont know what this is, contact your hosting provider and have them install this module for you as you wont be able to do it since you need to install runkit for this to work
  • Pecl Runkit - This is a Pear extension but is currently in BETA so it cannot be installed normally. The source is included since it's not viable to place a link to it otherwise. The project is in shambles in CVS but I've got my hands on a working version, patched it to work with php 5.2/5.3, and included it.
  • phpize command (Comes from php-devel in most distros)

Installing Runkit:
There are 2 ways to install runkit. If you are using PHP 5.1 or LESS then try this method first:

First Method:
Open a root SSH console and type the following:
pear install channel://pecl.php.net/runkit-0.9

If this actually works then start jumping like a mad man because that step will save you literally hours of work.
next edit php.ini and add this line

extension=runkit.so

Now restart apache and hope to god it works lol.
apachectl restart ('service httpd restart' on some servers)

Second Method (hope u dont have to do this but most people will :/ ):
Open a root SSH console and type the following:
cd /pathtodrupal/sites/all/modules/drupal_override_function
tar -zxvf runkit-with-php5.2+patch.tgz
cd runkit-with-php5.2+patch
phpize
./configure --prefix=/usr
patch -p0 < php-5.2+.patch
make
make install
vi /etc/php.ini
Add this line to php.ini:
extension=runkit.so
apachectl restart (or 'service httpd restart' on some servers)

These directions assume that your php exensions dir is at /usr/lib/php/extensions. If this is not where it lives, then change the prefix to wherever it is located (maybe /usr/local?)

Test it using the test module included with this module.

Installing APD:
pear -install pecl/APD (and hope to god it works, it likely wont lol). If this doesnt work, just abandon all hope and try with runkit instead.

APD NOTE: If you use the PECL Apd PHP Extension. You can find installation instructions here:
http://us2.php.net/manual/en/apd.setup.php NOTE: APD is NOT compatible with ZendOptimizer. Personally I dispise Zend because it encourages closed source software. Thus I am not a fan of Zend to begin with so I could careless if ZendOptimizer is disabled. I would rather use Runkit myself (which I do).

The ONLY time you need to be installing this, is if you are developing a module to use this module or another module is telling you to install it as a dependency. If you are not a developer or systems administrator and you need to install this, save yourself some time and find a QUALIFIED Linux/Unix systems administrator and have them install APD or Runkit and get it working before you even attempt to install this module. I do this as a service myself, contact me for rates.

WARNING! DO NOT attempt to override PHP functions using either APD or Runkit. They will BOTH puke randomly. It's simply not possible to do with either one of them at this time. But you can however override any other function you want (which includes ALL drupal functions, hooks, etc).

Development and maintenance by CrystalDawn.net & Kappaluppa Company

Project Information

  • Maintenance status: Unsupported
  • Development status: Obsolete
  • Module categories: Developer
  • Downloads: 2,061
  • Last modified: September 28, 2013

Downloads