Jump to content
Jim Yost

Module requirements check

Recommended Posts


When developing a module, is there any way for a requirements check before the module can be installed? Or perhaps a way to disable the install button if the module requires a certain version of php, or a certain module installed?

For instance, maybe my module requires calls to the W32api which is only available when installed on a Windows machine. I don't want it installed when running on PHP (that would be misleading).


Share this post

Link to post
Share on other sites

In your module, you can create an ___install() function, and an ___uninstall() function (if you want).

Do your requirements check in the install function that is a public method in your module class. For instance:


class YourModule extends WireData implements Module {

    // ....

    public function ___install() {
        $v = explode(".", phpversion());
        if($v[0] < 5 || ($v[0] == 5 && $v[1] < 3)) {
            throw new WireException("Sorry, your version of PHP is older than 5.3, can't install...");
    // ...


Also see /wire/core/Module.php, which contains the interface for modules. Most of the functions are optional, so they are commented out and there just for documentation/reference purposes.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...