PHP Configuration Requirements Checks

In order to verify PHP configuration, we may use "php-config" option in our "includes/steps.php" file and include necessary settings.

In this example lets add the following requirements:

  • PHP version must be at least 5.2
  • safe_mode must be disabled
  • register_globals must be disabled
  • allow_url_fopen must be enabled
  • upload_max_filesize must be at least 32mb

Our "includes/step.php" file should contain the code similar to this:

<?php
$steps 
= array(
  array(
    
'name' => 'Welcome to the wizard',
    
'fields' => array(
      array(
        
'type' => 'info',
        
'value' => 'Please verify that these requirements have been met.',
      ),
      array(
        
'type' => 'php-config',
        
'label' => 'PHP settings',
        
'items' => array(
          
'php_version' => array('>=5.2''PHP Version'),
          
'safe_mode' => false,
          
'register_globals' => false,
          
'allow_url_fopen' => true,
          
'upload_max_filesize' => '>=32mb',
        )
      )
    )
  )
);
?>

Lets look at it a bit closer. In the "items" array we specify a list of PHP settings we need to check, along with the necessary values. For example if we need to make sure that "safe_mode" is disabled, we set its value to "false". If we need to make sure "allow_url_fopen" is disabled, we set it to "false". We can also do math comparisons, such as "greater than =>", "less than <=" and "equal to =" as in our "upload_max_filesize" example. We simply include the comparison character in front of the value we need to compare it against. What we can also do is combine the setting's value with the name we'd like to display in our wizard by placing them in array. Thus instead of displaying "php_version", the wizard will display "PHP version". And lastly, we can set the item's value to "null" to simply display its PHP setting's value.

PHP Setup Wizard also allows you to check what PHP modules are enabled and loaded by using "php-modules" type in our "includes/steps.php" file. It works very similar to the PHP settings above. Lets look at this example:

<?php
$steps 
= array(
  array(
    
'name' => 'Welcome to the wizard',
    
'fields' => array(
      array(
        
'type' => 'info',
        
'value' => 'Please verify that these requirements have been met.',
      ),
      array(
        
'type' => 'php-modules',
        
'label' => 'PHP modules',
        
'items' => array(
          
'mysql' => array(true'MySQL'),
          
'ctype' => 'cType',
          
'zlib' => 'zType',
          
'ionCube Loader' => array(true'ionCube Loader'),
        )
      )
    )
  )
);
?>

The "items" array contains a list of PHP modules we'd like to make sure are loaded. The values can contain either a module name we'd like to display, or an array containing the required status of the module along with the name we'd like to display. For example "ctype" and "zlib" will both display that modules are either available or not. However "mysql" and "ioncube" indicate that both of these modules must be available to continue the wizard process.