Author: Fabien Potencier (fabien@symfony.com)
Inheritance: extends RequirementCollection
Example #1
0
 public function checkAction()
 {
     $data['page'] = 'check';
     require_once __DIR__ . '/../../../../app/SymfonyRequirements.php';
     $symfonyRequirements = new \SymfonyRequirements();
     $iniPath = $symfonyRequirements->getPhpIniConfigPath();
     $data['result'] = '
     <div class="alert alert-warning"><ul>
     ' . ($iniPath ? sprintf("<li>Configuration file used by PHP: %s</li>", $iniPath) : "<li>WARNING: No configuration file (php.ini) used by PHP!</li>") . '<li>The PHP CLI can use a different php.ini file</li>
     <li>than the one used with your web server.</li>';
     if ('\\' == DIRECTORY_SEPARATOR) {
         $data['result'] .= '<li>(especially on the Windows platform)</li>';
     }
     $data['result'] .= '<li>To be on the safe side, please also launch the requirements check</li>
     <li>from your web server using the web/config.php script.</li>
     </ul></div>';
     $data['result'] .= '<div class="table-responsive"><table id="checkTable" class="table table-striped">';
     $checkPassed = true;
     foreach ($symfonyRequirements->getRequirements() as $req) {
         /** @var $req Requirement */
         $data['result'] .= $this->echo_requirement($req);
         if (!$req->isFulfilled()) {
             $checkPassed = false;
         }
     }
     foreach ($symfonyRequirements->getRecommendations() as $req) {
         $data['result'] .= $this->echo_requirement($req);
     }
     $data['result'] .= '</table></div>';
     return $this->render('OjsInstallerBundle:Default:check.html.twig', array('data' => $data));
 }
 public function __construct()
 {
     parent::__construct();
     $phpVersion = phpversion();
     $gdVersion = defined('GD_VERSION') ? GD_VERSION : null;
     $curlVersion = function_exists('curl_version') ? curl_version() : null;
     $icuVersion = Intl::getIcuVersion();
     $this->addOroRequirement(version_compare($phpVersion, self::REQUIRED_PHP_VERSION, '>='), sprintf('PHP version must be at least %s (%s installed)', self::REQUIRED_PHP_VERSION, $phpVersion), sprintf('You are running PHP version "<strong>%s</strong>", but Oro needs at least PHP "<strong>%s</strong>" to run.
             Before using Oro, upgrade your PHP installation, preferably to the latest version.', $phpVersion, self::REQUIRED_PHP_VERSION), sprintf('Install PHP %s or newer (installed version is %s)', self::REQUIRED_PHP_VERSION, $phpVersion));
     $this->addOroRequirement(null !== $gdVersion && version_compare($gdVersion, self::REQUIRED_GD_VERSION, '>='), 'GD extension must be at least ' . self::REQUIRED_GD_VERSION, 'Install and enable the <strong>GD</strong> extension at least ' . self::REQUIRED_GD_VERSION . ' version');
     $this->addOroRequirement(function_exists('mcrypt_encrypt'), 'mcrypt_encrypt() should be available', 'Install and enable the <strong>Mcrypt</strong> extension.');
     $this->addOroRequirement(class_exists('Locale'), 'intl extension should be available', 'Install and enable the <strong>intl</strong> extension.');
     $this->addOroRequirement(null !== $icuVersion && version_compare($icuVersion, self::REQUIRED_ICU_VERSION, '>='), 'icu library must be at least ' . self::REQUIRED_ICU_VERSION, 'Install and enable the <strong>icu</strong> library at least ' . self::REQUIRED_ICU_VERSION . ' version');
     $this->addRecommendation(class_exists('SoapClient'), 'SOAP extension should be installed (API calls)', 'Install and enable the <strong>SOAP</strong> extension.');
     $this->addRecommendation(null !== $curlVersion && version_compare($curlVersion['version'], self::REQUIRED_CURL_VERSION, '>='), 'cURL extension must be at least ' . self::REQUIRED_CURL_VERSION, 'Install and enable the <strong>cURL</strong> extension at least ' . self::REQUIRED_CURL_VERSION . ' version');
     // Windows specific checks
     if (defined('PHP_WINDOWS_VERSION_BUILD')) {
         $this->addRecommendation(function_exists('finfo_open'), 'finfo_open() should be available', 'Install and enable the <strong>Fileinfo</strong> extension.');
         $this->addRecommendation(class_exists('COM'), 'COM extension should be installed', 'Install and enable the <strong>COM</strong> extension.');
     }
     $baseDir = realpath(__DIR__ . '/..');
     $mem = $this->getBytes(ini_get('memory_limit'));
     $this->addPhpIniRequirement('memory_limit', function ($cfgValue) use($mem) {
         return $mem >= 256 * 1024 * 1024 || -1 == $mem;
     }, false, 'memory_limit should be at least 256M', 'Set the "<strong>memory_limit</strong>" setting in php.ini<a href="#phpini">*</a> to at least "256M".');
     $directories = array('web/bundles', 'app/cache', 'app/logs', 'app/archive', 'app/uploads/product');
     foreach ($directories as $directory) {
         $this->addOroRequirement(is_writable($baseDir . '/' . $directory), $directory . ' directory must be writable', 'Change the permissions of the "<strong>' . $directory . '</strong>" directory so that the web server can write into it.');
     }
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function getRecommendations()
 {
     $recommendations = parent::getRecommendations();
     foreach ($recommendations as $key => $recommendation) {
         $testMessage = $recommendation->getTestMessage();
         if (preg_match_all(self::EXCLUDE_RECOMMENDED_MASK, $testMessage, $matches)) {
             unset($recommendations[$key]);
         }
     }
     return $recommendations;
 }
 public function __construct()
 {
     parent::__construct();
     // System call, e.g. to use Composer via command line, must be possible.
     $this->addRecommendation(function_exists('system'), 'system() should be available', 'Please enable the PHP function <strong>system()</strong>.');
     $this->addRecommendation(class_exists('IntlDateFormatter '), 'Internationalization Functions should be installed', 'Install and enable the <strong>PHP-INTL</strong> module: http://php.net/manual/en/intl.setup.php.');
     // /app/campaignchain must be writable.
     $campaignchainAppDir = __DIR__ . DIRECTORY_SEPARATOR . 'campaignchain';
     $this->addRequirement(is_writable($campaignchainAppDir), realpath($campaignchainAppDir) . ' must be writable', 'Change the permissions of "' . realpath($campaignchainAppDir) . '" directory so that the web server can write into it.');
     // /composer.json must be writable
     $composerJson = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'composer.json';
     $this->addRecommendation(is_writable($composerJson), realpath($composerJson) . ' should be writable', 'Change the permissions of "' . realpath($composerJson) . '" file if you would like to have the built-in modules dashboard work for users.');
     // /app/sessions must be writable.
     $campaignchainSessionsDir = __DIR__ . DIRECTORY_SEPARATOR . 'sessions';
     $this->addRequirement(is_writable($campaignchainSessionsDir), realpath($campaignchainSessionsDir) . ' must be writable', 'Change the permissions of "' . realpath($campaignchainSessionsDir) . '" directory so that the web server can write into it.');
 }
 /**
  * Check System Requirements
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function requirementsAction()
 {
     // include symfony requirements class
     require_once dirname(__FILE__) . '/../../../../app/SymfonyRequirements.php';
     $symfonyRequirements = new \SymfonyRequirements();
     // add additional requirement for mcrypt
     $symfonyRequirements->addRequirement(extension_loaded('mcrypt'), "Check if mcrypt ist loaded for RSA encryption", "Please enable mcrypt-Extension. See <a href='http://php.net/manual/de/mcrypt.setup.php'>http://php.net/manual/de/mcrypt.setup.php</a>");
     // fetch all data
     $aRequirements = $symfonyRequirements->getRequirements();
     $aRecommendations = $symfonyRequirements->getRecommendations();
     $aFailedRequirements = $symfonyRequirements->getFailedRequirements();
     $aFailedRecommendations = $symfonyRequirements->getFailedRecommendations();
     $iniPath = $symfonyRequirements->getPhpIniConfigPath();
     // render template
     return $this->render('SlashworksBackendBundle:Install:requirements.html.twig', array("iniPath" => $iniPath, "requirements" => $aRequirements, "recommendations" => $aRecommendations, "failedrequirements" => $aFailedRequirements, "failedrecommendations" => $aFailedRecommendations));
 }
 /**
  * Display form for license activation
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function aboutAction()
 {
     $oLicense = LicenseQuery::create()->findOne();
     // include symfony requirements class
     require_once dirname(__FILE__) . '/../../../../app/SymfonyRequirements.php';
     $symfonyRequirements = new \SymfonyRequirements();
     // add additional requirement for mcrypt
     $symfonyRequirements->addRequirement(extension_loaded('mcrypt'), "Check if mcrypt ist loaded for RSA encryption", "Please enable mcrypt-Extension. See <a href='http://php.net/manual/de/mcrypt.setup.php'>http://php.net/manual/de/mcrypt.setup.php</a>");
     // fetch all data
     $aRequirements = $symfonyRequirements->getRequirements();
     $aRecommendations = $symfonyRequirements->getRecommendations();
     $aFailedRequirements = $symfonyRequirements->getFailedRequirements();
     $aFailedRecommendations = $symfonyRequirements->getFailedRecommendations();
     $iniPath = $symfonyRequirements->getPhpIniConfigPath();
     $sVersion = file_get_contents(dirname(__FILE__) . '/../../../../version.txt');
     return $this->render('SlashworksAppBundle:About:about.html.twig', array("license" => $oLicense, "version" => $sVersion, "iniPath" => $iniPath, "requirements" => $aRequirements, "recommendations" => $aRecommendations, "failedrequirements" => $aFailedRequirements, "failedrecommendations" => $aFailedRecommendations));
 }
 /**
  * Constructor that initializes the requirements.
  */
 public function __construct()
 {
     parent::__construct();
     $this->addRequirement(ini_get("allow_url_fopen") || function_exists("curl_init"), sprintf('No way to remotely load files detected'), sprintf('Either set <strong>allow_url_fopen=true</strong> or install the cURL extension'));
     $this->addRequirement(function_exists("imagecreate"), sprintf('GD library not found'), sprintf('Install the GD library extension'));
     $this->addRequirement(function_exists("curl_init"), sprintf('CURL library not found'), sprintf('Install the GD library extension'));
     $this->addPhpIniRequirement("memory_limit", $this->getBytesIniSetting("memory_limit") > 128000000, false, "Memory Limit too small", sprintf("The php.ini memory_limit directive must be set to 128MB or higher. Your limit is set to %s", ini_get("memory_limit")));
     $this->checkWritable(realpath(dirname(__FILE__) . "/../data/"));
     $this->checkWritable(realpath(dirname(__FILE__) . "/../app/"));
     $this->checkWritable(realpath(dirname(__FILE__) . "/../web/"));
     $this->addRecommendation(function_exists("apc_fetch"), sprintf('PHP APCu cache not found'), sprintf('For best performance install the PHP APCu cache'));
     $this->addPhpIniRecommendation("max_execution_time", ini_get("max_execution_time") > 30, true, sprintf('Maximum Execution Time might be too low'), sprintf('Your maximum execution time is set to %d seconds, which might be too low for low-end systems. If you encounter problems, please increase the value.', ini_get("max_execution_time")));
     $this->addRequirement(function_exists("mb_convert_case"), sprintf('The PHP function mb_convert_case does not exist.'), sprintf('Please compile PHP with the mbstring functions in case you are using Gentoo, or install php-mbstring on RedHat, Fedora or CentOS.'));
     if (ini_get("opcache.enable")) {
         if (version_compare(phpversion(), "7.0", "<")) {
             $this->addPhpIniRequirement("opcache.save_comments", 1, false, "opcache.save_comments must be on", sprintf("The php.ini opcache.save_comments directive must be set to 1."));
             $this->addPhpIniRequirement("opcache.load_comments", 1, false, "opcache.load_comments must be on", sprintf("The php.ini opcache.load_comments directive must be set to 1."));
         }
     }
 }
Example #8
0
<?php

require_once dirname(__FILE__) . '/SymfonyRequirements.php';
$lineSize = 70;
$symfonyRequirements = new SymfonyRequirements();
$iniPath = $symfonyRequirements->getPhpIniConfigPath();
echo_title('Symfony2 Requirements Checker');
echo '> PHP is using the following php.ini file:' . PHP_EOL;
if ($iniPath) {
    echo_style('green', '  ' . $iniPath);
} else {
    echo_style('warning', '  WARNING: No configuration file (php.ini) used by PHP!');
}
echo PHP_EOL . PHP_EOL;
echo '> Checking Symfony requirements:' . PHP_EOL . '  ';
$messages = array();
foreach ($symfonyRequirements->getRequirements() as $req) {
    /** @var $req Requirement */
    if ($helpText = get_error_message($req, $lineSize)) {
        echo_style('red', 'E');
        $messages['error'][] = $helpText;
    } else {
        echo_style('green', '.');
    }
}
$checkPassed = empty($messages['error']);
foreach ($symfonyRequirements->getRecommendations() as $req) {
    if ($helpText = get_error_message($req, $lineSize)) {
        echo_style('yellow', 'W');
        $messages['warning'][] = $helpText;
    } else {
 /**
  * Checks if environment meets symfony requirements.
  *
  * @return $this
  */
 protected function checkSymfonyRequirements()
 {
     if (null === ($requirementsFile = $this->getSymfonyRequirementsFilePath())) {
         return $this;
     }
     try {
         require $requirementsFile;
         $symfonyRequirements = new \SymfonyRequirements();
         $this->requirementsErrors = array();
         foreach ($symfonyRequirements->getRequirements() as $req) {
             if ($helpText = $this->getErrorMessage($req)) {
                 $this->requirementsErrors[] = $helpText;
             }
         }
     } catch (MethodArgumentValueNotImplementedException $e) {
         // workaround https://github.com/symfony/symfony-installer/issues/163
     }
     return $this;
 }
 /**
  * Checks if environment meets symfony requirements.
  *
  * @return $this
  */
 protected function checkSymfonyRequirements()
 {
     try {
         $requirementsDir = $this->isSymfony3() ? 'var' : 'app';
         require $this->projectDir . '/' . $requirementsDir . '/SymfonyRequirements.php';
         $symfonyRequirements = new \SymfonyRequirements();
         $this->requirementsErrors = array();
         foreach ($symfonyRequirements->getRequirements() as $req) {
             if ($helpText = $this->getErrorMessage($req)) {
                 $this->requirementsErrors[] = $helpText;
             }
         }
     } catch (MethodArgumentValueNotImplementedException $e) {
         // workaround https://github.com/symfony/symfony-installer/issues/163
     }
     return $this;
 }
<?php

echo "Running testSymfonyRequirements.php...\n";
require_once dirname(__FILE__) . '/app/SymfonyRequirements.php';
$symfonyRequirements = new SymfonyRequirements();
$majorProblems = $symfonyRequirements->getFailedRequirements();
// Skip temporarily while ICU is an issue: https://github.com/sensiolabs/SensioDistributionBundle/issues/277
//$minorProblems = $symfonyRequirements->getFailedRecommendations();
$error = false;
if (!empty($majorProblems)) {
    var_dump($majorProblems);
    $error = true;
}
if (!empty($minorProblems)) {
    var_dump($minorProblems);
    $error = true;
}
if ($error) {
    echo "FAILED: See above for failed requirements and/or recommendations!\n";
    exit(1);
} else {
    echo "OK: No failed requirements or recommendations found!\n";
}
 /**
  * Check if system complies
  *
  * @return Response A Response instance
  */
 public function recommendationsAction()
 {
     $symfonyRequirements = new \SymfonyRequirements();
     $recommendations = $symfonyRequirements->getRecommendations();
     return $this->render("JumphInstallerBundle:Install:recommendations.html.twig", array('recommendations' => $recommendations));
 }
<?php

echo "Running testSymfonyRequirements.php...\n";
require_once dirname(__FILE__) . '/app/SymfonyRequirements.php';
$symfonyRequirements = new SymfonyRequirements();
$majorProblems = $symfonyRequirements->getFailedRequirements();
$minorProblems = $symfonyRequirements->getFailedRecommendations();
$error = false;
if (count($majorProblems) > 0) {
    var_dump($majorProblems);
    $error = true;
}
if (count($minorProblems) > 0) {
    var_dump($minorProblems);
    $error = true;
}
if ($error) {
    exit(1);
}
 /**
  * @see Console\Command\Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $container = $this->getApplication()->getKernel()->getContainer();
     $output->writeln('<info>Welcome to Newscoop Installer.<info>');
     $symfonyRequirements = new \SymfonyRequirements();
     $requirements = $symfonyRequirements->getRequirements();
     $missingReq = array();
     foreach ($requirements as $req) {
         if (!$req->isFulfilled()) {
             $missingReq[] = $req->getTestMessage() . ' - ' . $req->getHelpText();
         }
     }
     $fixCommonIssues = $input->getOption('fix');
     if (count($missingReq) > 0 && !$fixCommonIssues) {
         $output->writeln('<info>Before we start we need to fix some requirements.<info>');
         $output->writeln('<info>Please read all messages and try to fix them:<info>');
         foreach ($missingReq as $value) {
             $output->writeln('<error>' . $value . '<error>');
         }
         $output->writeln('<error>Use --fix param to fix those errors<error>');
         return;
     } elseif (count($missingReq) > 0 && $fixCommonIssues) {
         $newscoopDir = realpath(__DIR__ . '/../../../../../');
         // set chmods for directories
         exec('chmod -R 777 ' . $newscoopDir . '/cache/');
         exec('chmod -R 777 ' . $newscoopDir . '/log/');
         exec('chmod -R 777 ' . $newscoopDir . '/conf/');
         exec('chmod -R 777 ' . $newscoopDir . '/library/Proxy/');
         exec('chmod -R 777 ' . $newscoopDir . '/themes/');
         exec('chmod -R 777 ' . $newscoopDir . '/plugins/');
         exec('chmod -R 777 ' . $newscoopDir . '/public/');
         exec('chmod -R 777 ' . $newscoopDir . '/images/');
     }
     $dbParams = array('driver' => 'pdo_mysql', 'charset' => 'utf8', 'host' => $input->getOption('database_server_name'), 'dbname' => $input->getOption('database_name'), 'port' => $input->getOption('database_server_port'));
     if ($input->getOption('database_user')) {
         $dbParams['user'] = $input->getOption('database_user');
     }
     if ($input->getOption('database_password')) {
         $dbParams['password'] = $input->getOption('database_password');
     }
     $databaseService = new Services\DatabaseService($container->get('logger'));
     $finishService = new Services\FinishService();
     $demositeService = new Services\DemositeService($container->get('logger'));
     $connection = DriverManager::getConnection($dbParams);
     try {
         $connection->connect();
         if ($connection->getDatabase() === null) {
             $databaseService->createNewscoopDatabase($connection);
         }
     } catch (\Exception $e) {
         if ($e->getCode() == '1049') {
             $databaseService->createNewscoopDatabase($connection);
         } elseif (strpos($e->getMessage(), 'database exists') === false) {
             throw $e;
         }
     }
     $output->writeln('<info>Successfully connected to database.<info>');
     $tables = $connection->fetchAll('SHOW TABLES', array());
     if (count($tables) == 0 || $input->getOption('database_override')) {
         $databaseService->fillNewscoopDatabase($connection);
         $databaseService->loadGeoData($connection);
         $databaseService->saveDatabaseConfiguration($connection);
     } else {
         throw new \Exception('There is already a database named ' . $connection->getDatabase() . '. If you are sure to overwrite it, use option --database_override. If not, just change the Database Name and continue.', 1);
     }
     $command = $this->getApplication()->find('cache:clear');
     $arguments = array('command' => 'cache:clear', '--no-warmup' => true);
     $inputCache = new ArrayInput($arguments);
     $command->run($inputCache, $output);
     $databaseService->installDatabaseSchema($connection, $input->getArgument('alias'), $input->getArgument('site_title'));
     $output->writeln('<info>Database schema has been processed successfully.<info>');
     $demositeService->installEmptyTheme();
     $output->writeln('<info>Empty theme has been installed successfully.<info>');
     $clearEm = \Doctrine\ORM\EntityManager::create($connection, $container->get('em')->getConfiguration(), $connection->getEventManager());
     $finishService->saveCronjobs(new \Newscoop\Services\SchedulerService($clearEm));
     $output->writeln('<info>Cronjobs have been saved successfully<info>');
     $finishService->generateProxies();
     $output->writeln('<info>Proxies have been generated successfully<info>');
     $finishService->installAssets();
     $output->writeln('<info>Assets have been installed successfully<info>');
     $finishService->saveInstanceConfig(array('site_title' => $input->getArgument('site_title'), 'user_email' => $input->getArgument('user_email'), 'recheck_user_password' => $input->getArgument('user_password')), $connection);
     $output->writeln('<info>Config have been saved successfully.<info>');
     if (!$input->getOption('no-client')) {
         $finishService->createDefaultOauthClient($input->getArgument('alias'));
         $output->writeln('<info>Default OAuth client has been created successfully.<info>');
     }
     $output->writeln('<info>Newscoop is installed.<info>');
 }
Example #15
0
 public function checkSf2Recommendations()
 {
     $symfonyRequirements = new SymfonyRequirements();
     return $symfonyRequirements->getFailedRecommendations();
 }
Example #16
0
<?php

if (!isset($_SERVER['HTTP_HOST'])) {
    exit('This script cannot be run from the CLI. Run it from a browser.');
}
if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1'))) {
    header('HTTP/1.0 403 Forbidden');
    exit('This script is only accessible from localhost.');
}
require_once dirname(__FILE__) . '/../app/SymfonyRequirements.php';
$symfonyRequirements = new SymfonyRequirements();
$majorProblems = $symfonyRequirements->getFailedRequirements();
$minorProblems = $symfonyRequirements->getFailedRecommendations();
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" href="bundles/sensiodistribution/webconfigurator/css/install.css" media="all" />
        <title>Symfony Configuration</title>
    </head>
    <body>
        <div id="symfony-wrapper">
            <div id="symfony-content">
                <div class="symfony-blocks-install">
                    <div class="symfony-block-logo">
                        <img src="bundles/sensiodistribution/webconfigurator/images/logo-big.gif" alt="Symfony logo" />
                    </div>

                    <div class="symfony-block-content">
                        <h1>Welcome!</h1>
Example #17
0
 * @package Newscoop
 * @author Paweł Mikołajczuk <*****@*****.**>
 * @author Rafał Muszyński <*****@*****.**>
 * @copyright 2013 Sourcefabric o.p.s.
 * @license http://www.gnu.org/licenses/gpl-3.0.txt
 */
if (!file_exists(__DIR__ . '/../vendor') && !file_exists(__DIR__ . '/../vendor/autoload.php')) {
    echo "Welcome to Newscoop Installer!<br/><br/>";
    echo "It doesn't look like you've installed vendors yet. Please install all dependencies using Composer.";
    echo "<pre>curl -s https://getcomposer.org/installer | php <br/>php composer.phar install --no-dev</pre>";
    echo "When it's done, please refresh this page. Thanks!";
    die;
}
require_once __DIR__ . '/../vendor/autoload.php';
require_once dirname(__FILE__) . '/SymfonyRequirements.php';
$symfonyRequirements = new SymfonyRequirements();
$requirements = $symfonyRequirements->getRequirements();
$missingReq = array();
foreach ($requirements as $req) {
    if (!$req->isFulfilled()) {
        $missingReq[] = $req->getTestMessage() . '<br />      ' . $req->getHelpText() . '<br />';
    }
}
if (count($missingReq) > 0) {
    echo "Welcome to Newscoop Installer!<br/><br/>";
    echo "Before we will show You a real installer we need to fix some requirements first.<br />Please read all messages and try to fix them:<br />";
    echo "<pre>";
    foreach ($missingReq as $value) {
        echo $value . ' <br />';
    }
    echo "</pre>";