3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php if (! isset($autoloader)) { $autoloader = require __DIR__ . '/../../vendor/autoload.php'; } class CheckPlateform { //All values if not explicit //PHP version const MIN_ALLOWED_PHP_VERSION = "5.0.0"; const MAX_ALLOWED_PHP_VERSION = null;//excluded //Memory const MIN_ALLOWED_MEMORY_CLI = 512;//In M const MAX_ALLOWED_MEMORY_CLI = null;//In M const MIN_ALLOWED_MEMORY_WEB = 128;//In M const MAX_ALLOWED_MEMORY_WEB = null;//In M //Execution time const MIN_ALLOWED_EXECUTION_TIME_CLI = 30;//in s const MAX_ALLOWED_EXECUTION_TIME_CLI = null;//in s const MIN_ALLOWED_EXECUTION_TIME_WEB = 30;//in s const MAX_ALLOWED_EXECUTION_TIME_WEB = null;//in s //Internet access const CHECK_INTERNET_ACCESS = true;//or false //MySql const MYSQL_HOST = 'localhost';//or null const MIN_ALLOWED_MYSQL_VERSION = "5.5.0"; const MAX_ALLOWED_MYSQL_VERSION = null;//excluded //List of allowed handlers protected $expectedApi = array( 'cli', 'apache2handler' ); //List of necessary Apache modules protected $expectedApacheModules = array( 'mod_rewrite' ); //List of allowed operating systems protected $expectedOS = array( 'windows', 'linux' ); //List of allowed architectures protected $expectedArchitecture = array( 'amd64', 'x86_64' ); //List of necessary PHP extensions protected $expectedExtensions = array(//Extension name 'json', 'SPL', 'PDO', 'SimpleXML', 'curl', 'xsl' ); //List of necessary PHP classes protected $expectedClasses = array(//Class name 'Silex\Application', 'Monolog\Logger', 'Symfony\Component\Console\Application', 'Symfony\Component\Form\Form', 'Symfony\Component\Security\Core\SecurityContext', 'Symfony\Component\Translation\Translator', 'Symfony\Component\Validator\Validator', 'Swift_Mailer', 'Knp\Snappy\Pdf', 'Doctrine\ORM\EntityManager', 'Carbon\Carbon' ); //List of necessary files with access rights protected $expectedFileFolders = array(//Folder relative path form project root 'vendor/h4cc/wkhtmltopdf-amd64/bin/' => 'R', 'var/log' => 'RW', 'var' => 'RW' ); /* * DO NOT EDIT BELOW */ const METHOD_PREFIX = 'assert'; private $lineBreak; private $apiSuffix; public function __construct() { $this->lineBreak = ('cli' == php_sapi_name() ? "\n" : "<br/>"); $this->apiSuffix = ('cli' == php_sapi_name() ? "_CLI" : "_WEB"); } public function execute() { //Loop through all check methods by introspection $methods = get_class_methods(__CLASS__); $finalReturn = true; foreach ($methods as $method) { if (self::METHOD_PREFIX == substr($method, 0, strlen(self::METHOD_PREFIX))) { $return = $this->$method(); $finalReturn = $finalReturn && $return; echo str_pad($method, 50, '.') . ($return ? 'OK' : 'KO <<<') . $this->lineBreak; } } return $finalReturn; } protected function assertApi() { $api = php_sapi_name(); foreach ($this->expectedApi as $expectedApi) { if (0 == strcasecmp($api, $expectedApi)) { return true; } } echo 'Current API : ' . $api . $this->lineBreak; return false; } protected function assertOS() { $os = php_uname("s"); foreach ($this->expectedOS as $expectedOS) { if ( false !== stripos($os, $expectedOS)) { return true; } } echo 'Current OS : ' . $os . $this->lineBreak; return false; } protected function assertArchitecture() { $archi = php_uname("m"); foreach ($this->expectedArchitecture as $expectedArchitecture) { if (0 == strcasecmp($archi, $expectedArchitecture)) { return true; } } echo 'Current Architecture : ' . $archi . $this->lineBreak; return false; } protected function assertPhpVersion() { $return = true; if (!is_null(self::MIN_ALLOWED_PHP_VERSION)) { $return = version_compare(PHP_VERSION, self::MIN_ALLOWED_PHP_VERSION, '>='); } if (!is_null(self::MAX_ALLOWED_PHP_VERSION)) { $return = $return && version_compare(PHP_VERSION, self::MAX_ALLOWED_PHP_VERSION, '<'); } if(!$return) { echo 'Current PHP version : ' . phpversion() . $this->lineBreak; } return $return; } protected function assertMemory() { $mem = intval(ini_get('memory_limit')); $min = constant('self::MIN_ALLOWED_MEMORY' . $this->apiSuffix); $max = constant('self::MAX_ALLOWED_MEMORY' . $this->apiSuffix); $return = true; if (!is_null($min)) { $return = $mem >= $min; } if (!is_null($max)) { $return = $return && ($mem <= $max); } if(!$return) { echo 'Current memory : ' . $mem . $this->lineBreak; } return $return; } protected function assertExecutionTime() { $time = ini_get('max_execution_time'); $time = (0 != $time) ? $time : PHP_INT_MAX; $min = constant('self::MIN_ALLOWED_EXECUTION_TIME' . $this->apiSuffix); $max = constant('self::MAX_ALLOWED_EXECUTION_TIME' . $this->apiSuffix); $return = true; if (!is_null($min)) { $return = $time >= $max; } if (!is_null($max)) { $return = $time && ($mem <= $max); } if(!$return) { echo 'Current execution time : ' . $time . $this->lineBreak; } return $return; } protected function assertApacheModules() { if (!function_exists('apache_get_modules')) {//By-pass return true; } $modules = apache_get_modules(); foreach ($this->expectedApacheModules as $expectedApacheModule) { if (!in_array($expectedApacheModule, $modules)) { echo 'Missing module : ' . $expectedApacheModule . $this->lineBreak; return false; } } return true; } protected function assertExtensions() { $extensions = get_loaded_extensions(); foreach ($this->expectedExtensions as $expectedExtension) { if (!in_array($expectedExtension, $extensions)) { echo 'Missing extension : ' . $expectedExtension . $this->lineBreak; return false; } } return true; } protected function assertClasses() { foreach ($this->expectedClasses as $expectedClass) { if (!class_exists($expectedClass, true)) { echo 'Missing class : ' . $expectedExtension . $this->lineBreak; return false; } } return true; } protected function assertFilesFoldersExistenceAndAccessRights() { foreach ($this->expectedFileFolders as $expectedFileFolder => $rights) { $filepath = __DIR__ . '/../../' . $expectedFileFolder; if ((false !== stripos($rights, 'R')) && !is_readable($filepath)) { echo 'Cannot read file/folder : ' . $filepath . $this->lineBreak; return false; } if ((false !== stripos($rights, 'W')) && !is_writable($filepath)) { echo 'Cannot write file/folder : ' . $filepath . $this->lineBreak; return false; } } return true; } protected function assertInternetAccess() { if (!self::CHECK_INTERNET_ACCESS) { return true; } $connected = @fsockopen("www.free.fr", 80); if ($connected){ fclose($connected); return true; } return false; } protected function assertMySql() { if (is_null(self::MYSQL_HOST)) {//By-pass return true; } $link = mysqli_connect(self::MYSQL_HOST); if (false === $link) { echo 'Cannot access MySql : ' . $filepath . $this->lineBreak; return false; }; $version = mysqli_get_server_info($link); if (!is_null(self::MIN_ALLOWED_MYSQL_VERSION)) { $return = version_compare($version, self::MIN_ALLOWED_MYSQL_VERSION, '>='); } if (!is_null(self::MAX_ALLOWED_MYSQL_VERSION)) { $return = $return && version_compare($version, self::MAX_ALLOWED_MYSQL_VERSION, '<'); } if(!$return) { echo 'Current MySQL version : ' . $version . $this->lineBreak; } return $return; } } //Launch check return ((new CheckPlateform())->execute() ? 0 : -1);
Output for 5.4.0 - 5.6.28, 7.0.0 - 7.1.0
Warning: require(/in/../../vendor/autoload.php): failed to open stream: No such file or directory in /in/6RYkH on line 3 Fatal error: require(): Failed opening required '/in/../../vendor/autoload.php' (include_path='.:') in /in/6RYkH on line 3
Process exited with code 255.
Output for hhvm-3.13.2
Fatal error: Uncaught Error: require(/in/../../vendor/autoload.php): File not found in /in/6RYkH:3 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.12.0
Fatal error: Uncaught Error: File not found: /in/../../vendor/autoload.php in /in/6RYkH:3 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.10.0
Fatal error: File not found: /in/../../vendor/autoload.php in /in/6RYkH on line 3
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/6RYkH on line 284
Process exited with code 255.