PHP Classes

File: usage/usage.php

Recommend this page to a friend!
  Classes of Miraz Mac   Check PHP Requirements   usage/usage.php   Download  
File: usage/usage.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Check PHP Requirements
Verify conditions for a PHP application to run
Author: By
Last change:
Date: 4 years ago
Size: 1,162 bytes
 

Contents

Class file image Download
<?php

require '../vendor/autoload.php';

use
MirazMac\Requirements\Checker;

$checker = new Checker;

// Define requirements

// Make sure the PHP version is equal to or greater than 5.6
// Pass preferred php.ini values as an array
// Note the usage of boolean instead of On/1/Off/0

// Ensures allow_url_fopen is On

$checker->requirePhpVersion('>=5.6')
        ->
requirePhpExtensions(['ffmpeg', 'mbstring'])
        ->
requireFunctions(['random_bytes'])
        ->
requireFile('../composer.json', Checker::CHECK_FILE_EXISTS)
        ->
requireDirectory('../src', Checker::CHECK_IS_READABLE)
        ->
requireIniValues([
           
'allow_url_fopen' => true,
           
'short_open_tag' => true,
           
'memory_limit' => '>=64M',
        ]);

// Runs the check and returns parsed requirements as an array
// Contains parsed requirements with state of the current values and their comparison result
$output = $checker->check();


// Should be called after running check() to see if requirements has met or not
$satisfied = $checker->isSatisfied();

if (
$satisfied) {
    echo
"Requirements are met.";
} else {
    echo
join(', ', $checker->getErrors());
}