本文整理汇总了PHP中SymfonyRequirements类的典型用法代码示例。如果您正苦于以下问题:PHP SymfonyRequirements类的具体用法?PHP SymfonyRequirements怎么用?PHP SymfonyRequirements使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SymfonyRequirements类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkAction
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));
}
示例2: requirementsAction
/**
* 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));
}
示例3: aboutAction
/**
* 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));
}
示例4: dirname
<?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 {
示例5: checkSymfonyRequirements
/**
* 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;
}
示例6: checkSymfonyRequirements
/**
* 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;
}
示例7: dirname
<?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";
}
示例8: recommendationsAction
/**
* 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));
}
示例9: dirname
<?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);
}
示例10: execute
/**
* @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>');
}
示例11: checkSf2Recommendations
public function checkSf2Recommendations()
{
$symfonyRequirements = new SymfonyRequirements();
return $symfonyRequirements->getFailedRecommendations();
}
示例12: exit
<?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>
示例13: dirname
* @package Newscoop
* @author Paweł Mikołajczuk <pawel.mikolajczuk@sourcefabric.org>
* @author Rafał Muszyński <rafal.muszynski@sourcefabric.org>
* @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>";
示例14: __construct
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.');
}
}
示例15: getRecommendations
/**
* {@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;
}