PHP Classes

PHP Feature Test: Test if PHP features work on the current setup

Recommend this page to a friend!
  Info   View files Example   View files View files (16)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 47 All time: 10,683 This week: 107Up
Version License PHP version Categories
php-feature-test 1.0BSD License5PHP 5, Debug, Testing
Description 

Author

This package can test if PHP features work on the current setup.

It provides the main class that can call different driver classes to perform tests to evaluate if certain features work well on the PHP version that is installed in the current environment.

Each driver class works as a module to perform specific tests. Some drivers may just get information of the current PHP environment.

Currently it provides test classes to test:

- Connect to a MySQL server using the MySQLi extension functions

- Connect to a MySQL server using the MySQLi extension functions

- Encrypt and decrypt data using the OpenSSL extension functions

- Get information if the current PHP server API is Apache, FastCGI, CLI, etc..

- Check if the Sendmail program is available on the expected paths in Linux or UNIX environment for sending messages with the PHP mail function

- Check if it is possible to retrieve remote Web pages using SSL with the PHP file access functions

- Check if it is possible to use TrueType fonts to render text in images using the PHP GD extension

- Check if the PHP file upload progress extension is available

- Check if the Zend OpCache cache extension is available

- Check is the ZLib compression extension functions are available.

- Check the date and time extensions

Picture of Manuel Lemos
  Performance   Level  
Name: Manuel Lemos is available for providing paid consulting. Contact Manuel Lemos .
Classes: 45 packages by
Country: Portugal Portugal
Age: 55
All time rank: 1
Week rank: 2 Down1 in Portugal Portugal Equal

Example

<?php
/*
 * test.php
 *
 * @(#) $Id: test.php,v 1.12 2021/09/09 10:19:14 mlemos Exp $
 *
 */
   
require('feature_test.php');

   
/*
     * Create the feature test main object
     */
   
$feature_test = new feature_test_class;

   
/*
     * Set the configuration file that defines all the supported tests
     * You can create a new configuration file to perform other tests that
     * are not yet implemented by the current feature test driver classes.
     */
   
$feature_test->configuration_file = 'feature_test_configuration.json';

   
/*
     * Set the path of the feature test driver classes
     */
   
$feature_test->drivers_path = 'drivers';

   
/*
     * Set the html variable to determine whether you want the test
     * results to be outputted in plain text or HTML.
     */
   
$feature_test->html = defined('__HTML');

   
/*
     * Setup an options object with custom properties that will be used to
     * configure the driver classes.
     */
   
$options = new stdClass;
   
$options->database_type = 'mysqli';
   
$options->database_user = 'root';
   
$options->database_password = 'mysql password';
   
$options->database_host = 'localhost';
   
$options->database_name = 'database name';
   
$options->database_options = array();
   
$options->cipher = 'bf-ecb';
   
$options->ssl_url = 'https://www.phpclasses.org/';
   
$options->ssl_url_user = '';
   
$options->upload_progress = true;
   
$options->intl = true;
   
$options->strftime = false;

   
$feature_test->options = $options;

   
/*
     * If you want to run this test script from the command line shell,
     * you can pass the names of the tests that you want to perform,
     * just in case you just to perform some of the available tests.
     */
   
if(IsSet($_SERVER['argv'])
    &&
GetType($_SERVER['argv']) == 'array'
   
&& Count($_SERVER['argv']) > 1)
    {
       
$feature_test->test_list = $_SERVER['argv'];
       
array_shift($feature_test->test_list);
    }
    else
       
$feature_test->test_list = array();

   
/*
     * Call the class and output the results depending on whether the
     * tests failed or not.
     */
   
if(!$feature_test->Initialize()
    || !
$feature_test->Process()
    || !
$feature_test->Finalize())
        echo
'Failed tests: '.$feature_test->error."\n";
    else
        echo
$feature_test->Output();
?>


Details

PHP Feature Test

This package serves the purpose to test whether features of the PHP version being used in the current environment are available as required by the applications that each developer needs.

You can use this package to determine if your application is ready to run on newer PHP versions.

The package provides several built-in test driver classes that test whether different features are available and work well.

Run the test_features.php script to try this package.


  Files folder image Files  
File Role Description
Files folder imagedrivers (11 files)
Plain text file feature_test.php Class Class source
Accessible without login Plain text file feature_test_configuration.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file test_features.php Example Example script

  Files folder image Files  /  drivers  
File Role Description
  Plain text file date_and_time.php Class Class source
  Plain text file mysql.php Class Class source
  Plain text file mysqli.php Class Class source
  Plain text file openssl.php Class Class source
  Plain text file sapi.php Class Class source
  Plain text file sendmail.php Class Class source
  Plain text file ssl_client.php Class Class source
  Plain text file ttf.php Class Class source
  Plain text file upload_progress.php Class Class source
  Plain text file zend_opcache.php Class Class source
  Plain text file zlib.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:47
This week:0
All time:10,683
This week:107Up