/** * check if a server web is launched * @param array $options * @tutorial php bin/console server:status * php bin/console server:status -a 192.168.0.1:8000 */ public function status(array $options = array()) { ob_get_clean(); if (!isset($options['a'])) { $options['a'] = 'localhost:8000'; } list($hostname, $port) = explode(':', $options['a']); if (false !== ($fp = @fsockopen($hostname, $port, $errno, $errstr, 1))) { fclose($fp); echo "\n\n"; echo Bash::setBackground(" ", 'green'); echo Bash::setBackground(" [OK] A web server is launched ", 'green'); echo Bash::setBackground(" ", 'green'); echo "\n\n"; echo " > Check realized on " . $options['a']; echo "\n\n"; } else { echo "\n\n"; echo Bash::setBackground(" ", 'red'); echo Bash::setBackground(" [WARNING] A web server is not used ", 'red'); echo Bash::setBackground(" ", 'red'); echo "\n\n"; echo " > Check realized on " . $options['a']; echo "\n\n"; } }
/** * set the name of the called * * @access public * @return void */ private static function _setFileNameInErrorFile() { /** * We see if it's a cli call or a web call */ if (defined('BASH_CALLED')) { error_log(Bash::setColor('############### ' . BASH_CALLED . ' ###############', 'cyan')); } else { if (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) { error_log(Bash::setColor('############### ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . ' ###############', 'cyan')); } } }