diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..3606a43 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.tgz filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore index 73fe2a3..8a0c8f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,23 @@ -node_modules/ -vendor/ +/app/config/parameters.yml +/build/ +/phpunit.xml +/var/* +!/var/cache +/var/cache/* +!var/cache/.gitkeep +!/var/logs +/var/logs/* +!var/logs/.gitkeep +!/var/sessions +/var/sessions/* +!var/sessions/.gitkeep +!var/SymfonyRequirements.php +/vendor/ +/web/bundles/ +/web/js/ +/web/css/ *~ -lib/mysql/ +/lib +.idea +node_modules/ composer.lock -.idea/ -.php_cs.cache -app/logs/ -build/dist/ -cache/ -html/css/ -html/images/ -html/js/ -lib/ -variables.less diff --git a/Gruntfile.js b/Gruntfile.js index 25329d6..d29e7cd 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -16,7 +16,8 @@ module.exports = function (grunt) { vendor: { src: [ './vendor/bower/jquery/dist/jquery.js', - './vendor/bower/uikit/dist/js/uikit.js' + './vendor/bower/uikit/dist/js/uikit.js', + './vendor/bower/uikit/dist/js/uikit-icons.js' ], dest: 'build/dist/js/vendor.min.js' } @@ -81,21 +82,21 @@ module.exports = function (grunt) { expand: true, cwd: 'build/dist/js', src: ['*.min.js'], - dest: 'html/js', + dest: 'web/js', filter: 'isFile' }, { expand: true, cwd: 'build/dist/css', src: ['*.min.css'], - dest: 'html/css', + dest: 'web/css', filter: 'isFile' }, { expand: true, cwd: './vendor/bower/uikit/dist/images', src: ['**'], - dest: 'html/images' + dest: 'web/images' } ] } @@ -118,9 +119,9 @@ module.exports = function (grunt) { }, clean: [ 'build/dist', - 'html/js/*.js', - 'html/css/*.css', - 'html/images/*.svg' + 'web/js/*.js', + 'web/css/*.css', + 'web/images/*.svg' ] }); diff --git a/app/.htaccess b/app/.htaccess new file mode 100644 index 0000000..fb1de45 --- /dev/null +++ b/app/.htaccess @@ -0,0 +1,7 @@ + + Require all denied + + + Order deny,allow + Deny from all + diff --git a/app/AppCache.php b/app/AppCache.php new file mode 100644 index 0000000..639ec2c --- /dev/null +++ b/app/AppCache.php @@ -0,0 +1,7 @@ +getEnvironment(), ['dev', 'test'], true)) { + $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); + $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); + $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); + $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); + } + + return $bundles; + } + + public function getRootDir() + { + return __DIR__; + } + + public function getCacheDir() + { + return dirname(__DIR__).'/var/cache/'.$this->getEnvironment(); + } + + public function getLogDir() + { + return dirname(__DIR__).'/var/logs'; + } + + public function registerContainerConfiguration(LoaderInterface $loader) + { + $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml'); + } +} diff --git a/app/Kernel.php b/app/Kernel.php deleted file mode 100644 index 819eeef..0000000 --- a/app/Kernel.php +++ /dev/null @@ -1,406 +0,0 @@ -. - */ - -use Bramus\Monolog\Formatter\{ - ColorSchemes\TrafficLight, - ColoredLineFormatter -}; - -use Composer\Autoload\ClassLoader; -use Dflydev\Provider\DoctrineOrm\DoctrineOrmServiceProvider; -use Doctrine\Common\Annotations\AnnotationRegistry; -use Monolog\{ - Handler\StreamHandler, - Logger -}; -use Sikofitt\App\Entity\User; -use Sikofitt\App\Traits\EntityManagerTrait; -use Sikofitt\App\Traits\FlashTrait; -use Sikofitt\Security\MySqlUserProvider; -use Silex\Application; -use Silex\Application\{ - FormTrait, - MonologTrait, - SecurityTrait, - SwiftmailerTrait, - TranslationTrait, - TwigTrait, - UrlGeneratorTrait -}; -use Silex\Provider\{ - AssetServiceProvider, - CsrfServiceProvider, - DoctrineServiceProvider, - ExceptionHandlerServiceProvider, - FormServiceProvider, - HttpFragmentServiceProvider, - HttpKernelServiceProvider, - MonologServiceProvider, - RoutingServiceProvider, - SecurityServiceProvider, - ServiceControllerServiceProvider, - SessionServiceProvider, - SwiftmailerServiceProvider, - TwigServiceProvider, - ValidatorServiceProvider, - VarDumperServiceProvider, - WebProfilerServiceProvider -}; - -use Symfony\Bridge\Twig\Extension\TranslationExtension; -use Symfony\Component\Debug\ErrorHandler; -use Symfony\Component\Debug\ExceptionHandler; -use Symfony\Component\Form\FormFactory; -use Symfony\Component\Translation\Translator; - -/** - * Class Kernel. - */ -class Kernel extends Application -{ - use EntityManagerTrait; - use FlashTrait; - use FormTrait; - use MonologTrait; - use SecurityTrait; - use SwiftmailerTrait; - use TranslationTrait; - use TwigTrait; - use UrlGeneratorTrait; - - /** - * Kernel constructor. - * - * @param ClassLoader $loader - * @param bool $debug - * @param array $values - */ - public function __construct(ClassLoader $loader, bool $debug = false, array $values = []) - { - parent::__construct($values); - AnnotationRegistry::registerLoader([$loader, 'loadClass']); - if (true === $debug) { - $this->setDebug(); - } - - $this->setUpProviders(); - $this->setUpDatabase(); - $this->setUpView(); - $this->setUpLogger(); - $this->setUpMailer(); - } - - public function setUpRoutes(\Kernel $app) - { - } - - /** - * @param array $values - * - * @throws \InvalidArgumentException - * - * @return int - */ - public function mail(array $values) - { - if (false === isset($values['from']) || false === is_array($values['from'])) { - throw new \InvalidArgumentException('Array key "from" should be an array.'); - } elseif (false === isset($values['to']) || false === is_array($values['to'])) { - throw new \InvalidArgumentException('Array key "to" should be an array.'); - } elseif (false === isset($values['body']) || false === is_string($values['body'])) { - throw new \InvalidArgumentException('Array key "body" should be a string.'); - } elseif (false === isset($values['subject']) || false === is_string($values['subject'])) { - throw new \InvalidArgumentException('Array key "subject" should be a string.'); - } - - $message = \Swift_Message::newInstance(); - $message - ->setSubject($values['subject']) - ->setFrom($values['from']) - ->setTo($values['to']) - ->setBody($values['body']); - - /** - * @var \Swift_Transport $mailer - */ - $mailer = $this['mailer']; - - return $mailer->send($message); - } - - /** - * Sets the application to debug. - */ - public function setDebug() - { - $this['debug'] = true; - ErrorHandler::register(); - ExceptionHandler::register(); - } - - /** - * @return bool - */ - public function getDebug(): bool - { - return $this['debug']; - } - - /** - * @return string - */ - public function getBaseDir(): string - { - return __DIR__.'/..'; - } - - /** - * @return string - */ - public function getAppDir(): string - { - return $this->getBaseDir().'/app'; - } - - /** - * @return string - */ - public function getConfigDir(): string - { - return $this->getAppDir().'/config'; - } - - /** - * @return string - */ - public function getLogDir(): string - { - return $this->getAppDir().'/logs'; - } - - /** - * @return string - */ - public function getCacheDir(): string - { - return $this->getBaseDir().'/cache'; - } - - /** - * @return FormFactory - */ - public function getFormFactory() - { - return $this['form.factory']; - } - - /** - * Sets up the database environment. - */ - protected function setUpDatabase() - { - $this->register(new DoctrineServiceProvider(), [ - 'db.options' => [ - 'driver' => 'pdo_mysql', - 'dbname' => 'doughnut', - 'host' => 'mysql', - 'user' => 'doughnut', - 'password' => 'doughnut', - ], - ]); - //$j = new Doctrine\Common\Cache\FilesystemCache() - $this->register(new DoctrineOrmServiceProvider(), [ - 'orm.proxies_dir' => $this->getCacheDir().'/doctrine/proxies/Doughnut/Wedding', - 'orm.proxies_namespace' => 'Doughnut\Wedding', - 'orm.default_cache' => [ - 'driver' => 'filesystem', - 'path' => $this->getCacheDir().'/doctrine/cache', - ], - 'orm.auto_generate_proxies' => true, - 'orm.strategy' => 'naming', - 'orm.em.options' => [ - 'connection' => 'default', - 'mappings' => [ - [ - 'type' => 'annotation', - 'path' => $this->getBaseDir().'/src/Sikofitt/App/Entity', - 'namespace' => 'Sikofitt\App\Entity', - 'alias' => 'Sikofitt', - 'auto_generate_proxies' => true, - 'use_simple_annotation_reader' => false, - ], - ], - ], - ]); - } - - /** - * Sets up the view for the application. - */ - protected function setUpView() - { - $this - ->register(new HttpKernelServiceProvider()) - ->register(new RoutingServiceProvider()) - ->register(new AssetServiceProvider()) - ->register(new SessionServiceProvider()) - ->register(new HttpFragmentServiceProvider()) - ->register(new ServiceControllerServiceProvider()) - ->register(new ValidatorServiceProvider()); - - $this->register(new TwigServiceProvider(), [ - 'twig.path' => $this->getAppDir().'/views', - ]); - if (true === $this['debug']) { - $this - ->register(new VarDumperServiceProvider()) - ->register(new WebProfilerServiceProvider(), - [ - 'profiler.cache_dir' => $this->getCacheDir().'/profiler', - 'profiler.mount_prefix' => '/_profiler', - ]) - ->register(new ExceptionHandlerServiceProvider()) - ; - } - /* - * Closure supports \Twig_Environment and Silex\Application as a second - * parameter, but we never use Silex\Application so we leave it out. - */ - $this->extend('twig', function (\Twig_Environment $twig) { - $twig->addGlobal('session', $this['session']); - $twig->addExtension(new TranslationExtension(new Translator('en'))); - - return $twig; - }); - } - - /** - * Sets up the rest of the providers for the application. - */ - protected function setUpProviders() - { - /*$this['app.mysql_authenticator'] = function($app) { - return new Sikofitt\Security\MysqlAuthenticator($app['security.encoder_factory'], $app->getEntityManager()); - }; - $this['security.firewalls'] = array( - - 'login' => [ - 'pattern' => '^/login$', - 'anonymous' => true, - - - ], - 'secured' => [ - 'pattern' => '^/rsvp$', - 'guard' => [ - 'authenticators' => [ - 'app.mysql_authenticator', - ], - 'form' => [ - 'login_path' => '/login', - 'check_path' => '/login', - ] - - ], - - 'users' => $this['users'] = function() { - return new MySqlUserProvider($this['orm.em']); - }, - ], - - - // configure where your users come from. Hardcode them, or load them from somewhere - // http://silex.sensiolabs.org/doc/providers/security.html#defining-a-custom-user-provider - - // 'anonymous' => true - - );*/ - $this['protected_pages'] = function () { - return [ - 'gallery', - 'rsvp/update', - ]; - }; - - $this - - ->register(new CsrfServiceProvider()) - ->register(new FormServiceProvider()) - //->register(new SecurityServiceProvider()) - ; - - $this->extend('form.extensions', function ($extensions) { - return $extensions; - }); - } - - /** - * Sets up the logger for the application. - */ - protected function setUpLogger() - { - if (true === $this->getDebug()) { - $monologLevel = Logger::DEBUG; - } else { - $monologLevel = Logger::INFO; - } - $this->register(new MonologServiceProvider(), [ - 'monolog.logfile' => $this->getLogDir().'/'.$this->getEnvironment().'.log', - 'monolog.level' => $monologLevel, - ]); - $this->extend('monolog', function (Logger $monolog, Application $app) { - $streamHandler = new StreamHandler($app['monolog.logfile']); - $streamHandler->setFormatter(new ColoredLineFormatter(new TrafficLight())); - $monolog->pushHandler($streamHandler); - - return $monolog; - }); - } - - /** - * Sets up the mailer for the application. - */ - protected function setUpMailer() - { - $this['swiftmailer.options'] = [ - 'host' => 'mx.bgemi.net', - 'port' => '25', - 'username' => null, - 'password' => null, - 'encryption' => null, - 'auth_mode' => null, - ]; - $this->register(new SwiftmailerServiceProvider()); - } - - /** - * @return string - */ - protected function getEnvironment(): string - { - $appEnv = getenv('APP_ENV'); - - if (false === $appEnv) { - return 'development'; - } else { - return $appEnv; - } - } -} diff --git a/app/views/base.html.twig b/app/Resources/views/base.html.twig similarity index 100% rename from app/views/base.html.twig rename to app/Resources/views/base.html.twig diff --git a/app/Resources/views/default/index.html.twig b/app/Resources/views/default/index.html.twig new file mode 100644 index 0000000..1ce2bac --- /dev/null +++ b/app/Resources/views/default/index.html.twig @@ -0,0 +1,76 @@ +{% extends 'base.html.twig' %} + +{% block body %} +
+
+
+

Welcome to Symfony {{ constant('Symfony\\Component\\HttpKernel\\Kernel::VERSION') }}

+
+ +
+

+ + + Your application is now ready. You can start working on it at: + {{ base_dir }} +

+
+ + + +
+
+{% endblock %} + +{% block stylesheets %} + +{% endblock %} diff --git a/app/views/flash_messages.html.twig b/app/Resources/views/flash_messages.html.twig similarity index 100% rename from app/views/flash_messages.html.twig rename to app/Resources/views/flash_messages.html.twig diff --git a/app/views/form/token.html.twig b/app/Resources/views/form/token.html.twig similarity index 100% rename from app/views/form/token.html.twig rename to app/Resources/views/form/token.html.twig diff --git a/app/views/form_errors.html.twig b/app/Resources/views/form_errors.html.twig similarity index 100% rename from app/views/form_errors.html.twig rename to app/Resources/views/form_errors.html.twig diff --git a/app/views/index.html.twig b/app/Resources/views/index.html.twig similarity index 100% rename from app/views/index.html.twig rename to app/Resources/views/index.html.twig diff --git a/app/views/login.html.twig b/app/Resources/views/login.html.twig similarity index 100% rename from app/views/login.html.twig rename to app/Resources/views/login.html.twig diff --git a/app/views/reset_password.html.twig b/app/Resources/views/reset_password.html.twig similarity index 100% rename from app/views/reset_password.html.twig rename to app/Resources/views/reset_password.html.twig diff --git a/app/views/reset_password_confirm.html.twig b/app/Resources/views/reset_password_confirm.html.twig similarity index 100% rename from app/views/reset_password_confirm.html.twig rename to app/Resources/views/reset_password_confirm.html.twig diff --git a/app/views/reset_password_token.html.twig b/app/Resources/views/reset_password_token.html.twig similarity index 100% rename from app/views/reset_password_token.html.twig rename to app/Resources/views/reset_password_token.html.twig diff --git a/app/views/rsvp_form.html.twig b/app/Resources/views/rsvp_form.html.twig similarity index 100% rename from app/views/rsvp_form.html.twig rename to app/Resources/views/rsvp_form.html.twig diff --git a/app/views/user/index.html.twig b/app/Resources/views/user/index.html.twig similarity index 100% rename from app/views/user/index.html.twig rename to app/Resources/views/user/index.html.twig diff --git a/app/views/user/logout.html.twig b/app/Resources/views/user/logout.html.twig similarity index 100% rename from app/views/user/logout.html.twig rename to app/Resources/views/user/logout.html.twig diff --git a/app/autoload.php b/app/autoload.php new file mode 100644 index 0000000..31321fa --- /dev/null +++ b/app/autoload.php @@ -0,0 +1,11 @@ +getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev'); +$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod'; + +if ($debug) { + Debug::enable(); +} + +$kernel = new AppKernel($env, $debug); +$application = new Application($kernel); +$application->run($input); diff --git a/bin/console.php b/bin/console.php deleted file mode 100755 index 1c15ab4..0000000 --- a/bin/console.php +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env php -. - */ - -use Knp\Provider\ConsoleServiceProvider; -use Sikofitt\App\Provider\DoctrineConsoleProvider; -use Symfony\Bridge\Twig\Command\DebugCommand; -use Symfony\Bridge\Twig\Command\LintCommand; - -$loader = require __DIR__.'/../vendor/autoload.php'; -$app = new \Kernel($loader, true); -$consoleConfig = [ - 'console.name' => 'Doughnut Wedding', - 'console.version' => '0.0.2', - 'console.project_directory' => __DIR__.'/..', -]; - -$app - ->register(new ConsoleServiceProvider(), $consoleConfig) - ->register(new DoctrineConsoleProvider()); - -$fixCommand = new \PhpCsFixer\Console\Command\FixCommand(); -$fixCommand->setName('dev:fixer')->setDescription('PhpCSFixer - Fixes directories and files according to a set of rules.'); -$twigLintCommand = new LintCommand(); -$twigLintCommand->setTwigEnvironment($app['twig']); -$twigDebugCommand = new DebugCommand(); -$twigDebugCommand->setTwigEnvironment($app['twig']); -$fixCommand->setHidden(true); - -$app['console']->addCommands([ - $twigDebugCommand, - $twigLintCommand, - new \Symfony\Component\Yaml\Command\LintCommand(), - $fixCommand, -]); - -$app['console']->run(); diff --git a/bin/symfony_requirements b/bin/symfony_requirements new file mode 100755 index 0000000..a7bf65a --- /dev/null +++ b/bin/symfony_requirements @@ -0,0 +1,146 @@ +#!/usr/bin/env php +getPhpIniConfigPath(); + +echo_title('Symfony Requirements Checker'); + +echo '> PHP is using the following php.ini file:'.PHP_EOL; +if ($iniPath) { + echo_style('green', ' '.$iniPath); +} else { + echo_style('yellow', ' 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) { + 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 { + echo_style('green', '.'); + } +} + +if ($checkPassed) { + echo_block('success', 'OK', 'Your system is ready to run Symfony projects'); +} else { + echo_block('error', 'ERROR', 'Your system is not ready to run Symfony projects'); + + echo_title('Fix the following mandatory requirements', 'red'); + + foreach ($messages['error'] as $helpText) { + echo ' * '.$helpText.PHP_EOL; + } +} + +if (!empty($messages['warning'])) { + echo_title('Optional recommendations to improve your setup', 'yellow'); + + foreach ($messages['warning'] as $helpText) { + echo ' * '.$helpText.PHP_EOL; + } +} + +echo PHP_EOL; +echo_style('title', 'Note'); +echo ' The command console could use a different php.ini file'.PHP_EOL; +echo_style('title', '~~~~'); +echo ' than the one used with your web server. To be on the'.PHP_EOL; +echo ' safe side, please check the requirements from your web'.PHP_EOL; +echo ' server using the '; +echo_style('yellow', 'web/config.php'); +echo ' script.'.PHP_EOL; +echo PHP_EOL; + +exit($checkPassed ? 0 : 1); + +function get_error_message(Requirement $requirement, $lineSize) +{ + if ($requirement->isFulfilled()) { + return; + } + + $errorMessage = wordwrap($requirement->getTestMessage(), $lineSize - 3, PHP_EOL.' ').PHP_EOL; + $errorMessage .= ' > '.wordwrap($requirement->getHelpText(), $lineSize - 5, PHP_EOL.' > ').PHP_EOL; + + return $errorMessage; +} + +function echo_title($title, $style = null) +{ + $style = $style ?: 'title'; + + echo PHP_EOL; + echo_style($style, $title.PHP_EOL); + echo_style($style, str_repeat('~', strlen($title)).PHP_EOL); + echo PHP_EOL; +} + +function echo_style($style, $message) +{ + // ANSI color codes + $styles = array( + 'reset' => "\033[0m", + 'red' => "\033[31m", + 'green' => "\033[32m", + 'yellow' => "\033[33m", + 'error' => "\033[37;41m", + 'success' => "\033[37;42m", + 'title' => "\033[34m", + ); + $supports = has_color_support(); + + echo($supports ? $styles[$style] : '').$message.($supports ? $styles['reset'] : ''); +} + +function echo_block($style, $title, $message) +{ + $message = ' '.trim($message).' '; + $width = strlen($message); + + echo PHP_EOL.PHP_EOL; + + echo_style($style, str_repeat(' ', $width)); + echo PHP_EOL; + echo_style($style, str_pad(' ['.$title.']', $width, ' ', STR_PAD_RIGHT)); + echo PHP_EOL; + echo_style($style, $message); + echo PHP_EOL; + echo_style($style, str_repeat(' ', $width)); + echo PHP_EOL; +} + +function has_color_support() +{ + static $support; + + if (null === $support) { + if (DIRECTORY_SEPARATOR == '\\') { + $support = false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI'); + } else { + $support = function_exists('posix_isatty') && @posix_isatty(STDOUT); + } + } + + return $support; +} diff --git a/bower.json b/bower.json index 380d303..7276b06 100644 --- a/bower.json +++ b/bower.json @@ -21,6 +21,7 @@ ], "dependencies": { "uikit": "3", - "jquery": "^3.1.1" + "jquery": "^3.1.1", + "parsleyjs": "^2.7.0" } } diff --git a/composer.json b/composer.json index a9f9620..a302028 100644 --- a/composer.json +++ b/composer.json @@ -1,67 +1,97 @@ { - "name": "sikofitt/doughnutwedding", - "description": "doughnutwedding.com website", + "name": "symfony/framework-standard-edition", + "license": "MIT", "type": "project", + "description": "The \"Symfony Standard Edition\" distribution", + "autoload": { + "psr-4": { "Sikofitt\\": "src/Sikofitt/" }, + "classmap": [ "app/AppKernel.php", "app/AppCache.php" ] + }, + "autoload-dev": { + "psr-4": { "Tests\\": "tests/" }, + "files": [ "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php" ] + }, "require": { - "php": ">=7.0", - "bramus/monolog-colored-line-formatter": "~2.0", - "container-interop/container-interop": "^1.1", - "dflydev/doctrine-orm-service-provider": "^2.0", - "doctrine/annotations": "^1.3", - "doctrine/collections": "^1.4", - "doctrine/dbal": "^2.5", + "php": ">=7.1", + "bramus/monolog-colored-line-formatter": "^2.0", + "doctrine/doctrine-bundle": "^1.6", + "doctrine/doctrine-cache-bundle": "^1.2", "doctrine/orm": "^2.5", "egulias/email-validator": "^2.1", "google/recaptcha": "^1.1", + "incenteev/composer-parameter-handler": "^2.0", "ircmaxell/random-lib": "^1.2", "ircmaxell/security-lib": "^1.1", - "knplabs/console-service-provider": "^2.0", - "monolog/monolog": "^1.22", + "j-ben87/parsley-bundle": "^1.4", + "javiereguiluz/easyadmin-bundle": "^1.16", + "lexik/translation-bundle": "^4.0", + "lightsaml/sp-bundle": "^1.1", + "moontoast/math": "^1.1", "paragonie/cookie": "^3.1", "paragonie/csp-builder": "^2.0", - "paragonie/sodium_compat": "^0.4.0", - "silex/silex": "^2.0", - "swiftmailer/swiftmailer": "^5.4", - "symfony/asset": "^3.2", - "symfony/config": "^3.2", - "symfony/console": "^3.2", - "symfony/form": "^3.2", - "symfony/http-foundation": "^3.2", - "symfony/monolog-bridge": "^3.2", + "paragonie/sodium_compat": "^0.6.0", + "predis/predis": "^1.1", + "psr/http-message": "^1.0", + "ramsey/uuid": "^3.5", + "ramsey/uuid-doctrine": "^1.2", + "ravenberg/uikit-bundle": "^1.0", + "sensio/distribution-bundle": "^5.0", + "sensio/framework-extra-bundle": "^3.0.2", + "symfony/monolog-bundle": "^3.0.2", + "symfony/polyfill-apcu": "^1.0", + "symfony/security": "^3.2", "symfony/security-csrf": "^3.2", "symfony/security-guard": "^3.2", "symfony/security-http": "^3.2", - "symfony/twig-bridge": "^3.2", - "symfony/validator": "^3.2", - "symfony/yaml": "^3.2", + "symfony/swiftmailer-bundle": "^2.3.10", + "symfony/symfony": "3.2.*", "tedivm/stash": "^0.14.1", "twig/extensions": "^1.4", - "twig/twig": "^2.1" + "twig/twig": "^1.0||^2.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.0", + "doctrine/doctrine-fixtures-bundle": "^2.3", + "friendsofphp/php-cs-fixer": "^2.1", "fzaninotto/faker": "^1.6", - "phpunit/phpunit": "^6.0", - "silex/providers": "^2.0", - "silex/web-profiler": "^2.0", + "sensio/generator-bundle": "^3.0", "symfony/debug-bundle": "^3.2", + "symfony/phpunit-bridge": "^3.0", "symfony/var-dumper": "^3.2" }, - "autoload": { - "psr-4": { - "Sikofitt\\":"src/Sikofitt" - }, - "files": ["app/Kernel.php"] + "scripts": { + "symfony-scripts": [ + "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", + "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", + "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", + "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", + "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", + "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget" + ], + "post-install-cmd": [ + "@symfony-scripts" + ], + "post-update-cmd": [ + "@symfony-scripts" + ] }, - "license": "GPL-3.0", - "authors": [ - { - "name": "sikofitt", - "email": "sikofitt@gmail.com" + "config": { + "platform": { + "php": "7.1.3" + }, + "sort-packages": true + }, + "extra": { + "symfony-app-dir": "app", + "symfony-bin-dir": "bin", + "symfony-var-dir": "var", + "symfony-web-dir": "web", + "symfony-tests-dir": "tests", + "symfony-assets-install": "relative", + "incenteev-parameters": { + "file": "app/config/parameters.yml" + }, + "branch-alias": { + "dev-master": "3.2-dev" } - ], - "minimum-stability": "stable", - "config": { - "sort-packages": true - } + } } diff --git a/conf.d/default.conf b/conf.d/default.conf index dd06684..26c2e18 100644 --- a/conf.d/default.conf +++ b/conf.d/default.conf @@ -8,14 +8,14 @@ server { location / { index index.php index.html; - try_files $uri /index.php$is_args$args; + try_files $uri /app_dev.php$is_args$args; } location ~ \.php$ { include fastcgi_params; fastcgi_pass php:9000; - fastcgi_index index.php; + fastcgi_index app_dev.php; fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; } diff --git a/docker-compose.yml b/docker-compose.yml index e239392..76b1f41 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,7 @@ services: links: - php - mysql + - redis restart: always environment: - "APP_ENV=development" @@ -19,7 +20,7 @@ services: build: ./docker/php volumes: - ./:/var/www - - ./html:/var/www/html + - ./web:/var/www/html restart: always environment: - "APP_ENV=development" @@ -34,4 +35,8 @@ services: - "3306:3306" volumes: - ./lib/mysql:/var/lib/mysql - \ No newline at end of file + redis: + build: ./docker/redis + ports: + - "6379:6379" + \ No newline at end of file diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index 699c458..eda1c51 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.0-fpm-alpine +FROM php:7.1-fpm-alpine ENV PHPIZE_DEPS \ autoconf \ @@ -9,15 +9,38 @@ ENV PHPIZE_DEPS \ make \ pkgconf \ re2c \ - icu-dev \ - sqlite-dev + sqlite-dev \ + hiredis-dev \ + git -RUN apk update && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS && apk add icu-libs icu +RUN apk update && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS && apk add hiredis libstdc++ + +COPY ./icu4c-58_2-src.tgz /tmp + +RUN ln -s /usr/include/locale.h /usr/include/xlocale.h && \ + cd /tmp && \ + tar -xvf ./icu4c-58_2-src.tgz && \ + cd /tmp/icu/source && \ + ./runConfigureICU Linux && \ + make && make install && cd && rm -rf /tmp/icu + + + +RUN /usr/local/bin/docker-php-ext-install pdo_mysql intl opcache -RUN /usr/local/bin/docker-php-ext-install pdo_mysql intl RUN echo "y\n"|pecl install scrypt && /usr/local/bin/docker-php-ext-enable scrypt RUN echo "y\n"|pecl install xdebug && /usr/local/bin/docker-php-ext-enable xdebug -RUN apk del .build-deps +# RUN echo "n\n"|pecl install apcu && /usr/local/bin/docker-php-ext-enable apcu +RUN pecl install redis && /usr/local/bin/docker-php-ext-enable redis -COPY ./php.ini /usr/local/etc/php \ No newline at end of file +RUN git clone https://github.com/nrk/phpiredis.git /tmp/phpiredis && \ + cd /tmp/phpiredis && \ + phpize && \ + ./configure --enable-phpiredis && \ + make && make install && /usr/local/bin/docker-php-ext-enable phpiredis + + +RUN apk del .build-deps && apk del git + +COPY ./php.ini /usr/local/etc/php diff --git a/docker/php/icu4c-58_2-src.tgz b/docker/php/icu4c-58_2-src.tgz new file mode 100644 index 0000000..a3a2400 --- /dev/null +++ b/docker/php/icu4c-58_2-src.tgz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2b0a4410153a9b20de0e20c7d8b66049a72aef244b53683d0d7521371683da0c +size 23369902 diff --git a/docker/redis/Dockerfile b/docker/redis/Dockerfile new file mode 100644 index 0000000..3d2abd4 --- /dev/null +++ b/docker/redis/Dockerfile @@ -0,0 +1,7 @@ +FROM redis:3 +COPY ./redis.conf /usr/local/etc/redis/redis.conf +RUN mkdir /var/lib/redis && \ + mkdir /var/log/redis && \ + chown redis.redis /var/lib/redis && \ + chown redis.redis /var/log/redis +CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ] diff --git a/docker/redis/redis.conf b/docker/redis/redis.conf new file mode 100644 index 0000000..f88b0c3 --- /dev/null +++ b/docker/redis/redis.conf @@ -0,0 +1,1023 @@ +# Redis configuration file example. +# +# Note that in order to read the configuration file, Redis must be +# started with the file path as first argument: +# +# ./redis-server /path/to/redis.conf + +# Note on units: when memory size is needed, it is possible to specify +# it in the usual form of 1k 5GB 4M and so forth: +# +# 1k => 1000 bytes +# 1kb => 1024 bytes +# 1m => 1000000 bytes +# 1mb => 1024*1024 bytes +# 1g => 1000000000 bytes +# 1gb => 1024*1024*1024 bytes +# +# units are case insensitive so 1GB 1Gb 1gB are all the same. + +################################## INCLUDES ################################### + +# Include one or more other config files here. This is useful if you +# have a standard template that goes to all Redis servers but also need +# to customize a few per-server settings. Include files can include +# other files, so use this wisely. +# +# Notice option "include" won't be rewritten by command "CONFIG REWRITE" +# from admin or Redis Sentinel. Since Redis always uses the last processed +# line as value of a configuration directive, you'd better put includes +# at the beginning of this file to avoid overwriting config change at runtime. +# +# If instead you are interested in using includes to override configuration +# options, it is better to use include as the last line. +# +# include /path/to/local.conf +# include /path/to/other.conf + +################################## NETWORK ##################################### + +# By default, if no "bind" configuration directive is specified, Redis listens +# for connections from all the network interfaces available on the server. +# It is possible to listen to just one or multiple selected interfaces using +# the "bind" configuration directive, followed by one or more IP addresses. +# +# Examples: +# +# bind 192.168.1.100 10.0.0.1 +# bind 127.0.0.1 ::1 +# +# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the +# internet, binding to all the interfaces is dangerous and will expose the +# instance to everybody on the internet. So by default we uncomment the +# following bind directive, that will force Redis to listen only into +# the IPv4 lookback interface address (this means Redis will be able to +# accept connections only from clients running into the same computer it +# is running). +# +# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES +# JUST COMMENT THE FOLLOWING LINE. +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# bind 127.0.0.1 + +# Protected mode is a layer of security protection, in order to avoid that +# Redis instances left open on the internet are accessed and exploited. +# +# When protected mode is on and if: +# +# 1) The server is not binding explicitly to a set of addresses using the +# "bind" directive. +# 2) No password is configured. +# +# The server only accepts connections from clients connecting from the +# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain +# sockets. +# +# By default protected mode is enabled. You should disable it only if +# you are sure you want clients from other hosts to connect to Redis +# even if no authentication is configured, nor a specific set of interfaces +# are explicitly listed using the "bind" directive. +protected-mode no + +# Accept connections on the specified port, default is 6379 (IANA #815344). +# If port 0 is specified Redis will not listen on a TCP socket. +port 6379 + +# TCP listen() backlog. +# +# In high requests-per-second environments you need an high backlog in order +# to avoid slow clients connections issues. Note that the Linux kernel +# will silently truncate it to the value of /proc/sys/net/core/somaxconn so +# make sure to raise both the value of somaxconn and tcp_max_syn_backlog +# in order to get the desired effect. +tcp-backlog 511 + +# Unix socket. +# +# Specify the path for the Unix socket that will be used to listen for +# incoming connections. There is no default, so Redis will not listen +# on a unix socket when not specified. +# +# unixsocket /var/run/redis/redis.sock +# unixsocketperm 700 + +# Close the connection after a client is idle for N seconds (0 to disable) +timeout 0 + +# TCP keepalive. +# +# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence +# of communication. This is useful for two reasons: +# +# 1) Detect dead peers. +# 2) Take the connection alive from the point of view of network +# equipment in the middle. +# +# On Linux, the specified value (in seconds) is the period used to send ACKs. +# Note that to close the connection the double of the time is needed. +# On other kernels the period depends on the kernel configuration. +# +# A reasonable value for this option is 300 seconds, which is the new +# Redis default starting with Redis 3.2.1. +tcp-keepalive 300 + +################################# GENERAL ##################################### + +# By default Redis does not run as a daemon. Use 'yes' if you need it. +# Note that Redis will write a pid file in /var/run/redis.pid when daemonized. +daemonize no + +# If you run Redis from upstart or systemd, Redis can interact with your +# supervision tree. Options: +# supervised no - no supervision interaction +# supervised upstart - signal upstart by putting Redis into SIGSTOP mode +# supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET +# supervised auto - detect upstart or systemd method based on +# UPSTART_JOB or NOTIFY_SOCKET environment variables +# Note: these supervision methods only signal "process is ready." +# They do not enable continuous liveness pings back to your supervisor. +supervised no + +# If a pid file is specified, Redis writes it where specified at startup +# and removes it at exit. +# +# When the server runs non daemonized, no pid file is created if none is +# specified in the configuration. When the server is daemonized, the pid file +# is used even if not specified, defaulting to "/var/run/redis.pid". +# +# Creating a pid file is best effort: if Redis is not able to create it +# nothing bad happens, the server will start and run normally. +pidfile /var/run/redis/redis-server.pid + +# Specify the server verbosity level. +# This can be one of: +# debug (a lot of information, useful for development/testing) +# verbose (many rarely useful info, but not a mess like the debug level) +# notice (moderately verbose, what you want in production probably) +# warning (only very important / critical messages are logged) +loglevel debug + +# Specify the log file name. Also the empty string can be used to force +# Redis to log on the standard output. Note that if you use standard +# output for logging but daemonize, logs will be sent to /dev/null +logfile /var/log/redis/redis-server.log + +# To enable logging to the system logger, just set 'syslog-enabled' to yes, +# and optionally update the other syslog parameters to suit your needs. +syslog-enabled no + +# Specify the syslog identity. +syslog-ident redis + +# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7. +syslog-facility local0 + +# Set the number of databases. The default database is DB 0, you can select +# a different one on a per-connection basis using SELECT where +# dbid is a number between 0 and 'databases'-1 +databases 16 + +################################ SNAPSHOTTING ################################ +# +# Save the DB on disk: +# +# save +# +# Will save the DB if both the given number of seconds and the given +# number of write operations against the DB occurred. +# +# In the example below the behaviour will be to save: +# after 900 sec (15 min) if at least 1 key changed +# after 300 sec (5 min) if at least 10 keys changed +# after 60 sec if at least 10000 keys changed +# +# Note: you can disable saving completely by commenting out all "save" lines. +# +# It is also possible to remove all the previously configured save +# points by adding a save directive with a single empty string argument +# like in the following example: +# +# save "" + +save 900 1 +save 300 10 +save 60 10000 + +# By default Redis will stop accepting writes if RDB snapshots are enabled +# (at least one save point) and the latest background save failed. +# This will make the user aware (in a hard way) that data is not persisting +# on disk properly, otherwise chances are that no one will notice and some +# disaster will happen. +# +# If the background saving process will start working again Redis will +# automatically allow writes again. +# +# However if you have setup your proper monitoring of the Redis server +# and persistence, you may want to disable this feature so that Redis will +# continue to work as usual even if there are problems with disk, +# permissions, and so forth. +stop-writes-on-bgsave-error yes + +# Compress string objects using LZF when dump .rdb databases? +# For default that's set to 'yes' as it's almost always a win. +# If you want to save some CPU in the saving child set it to 'no' but +# the dataset will likely be bigger if you have compressible values or keys. +rdbcompression yes + +# Since version 5 of RDB a CRC64 checksum is placed at the end of the file. +# This makes the format more resistant to corruption but there is a performance +# hit to pay (around 10%) when saving and loading RDB files, so you can disable it +# for maximum performances. +# +# RDB files created with checksum disabled have a checksum of zero that will +# tell the loading code to skip the check. +rdbchecksum yes + +# The filename where to dump the DB +dbfilename dump.rdb + +# The working directory. +# +# The DB will be written inside this directory, with the filename specified +# above using the 'dbfilename' configuration directive. +# +# The Append Only File will also be created inside this directory. +# +# Note that you must specify a directory here, not a file name. +dir /var/lib/redis + +################################# REPLICATION ################################# + +# Master-Slave replication. Use slaveof to make a Redis instance a copy of +# another Redis server. A few things to understand ASAP about Redis replication. +# +# 1) Redis replication is asynchronous, but you can configure a master to +# stop accepting writes if it appears to be not connected with at least +# a given number of slaves. +# 2) Redis slaves are able to perform a partial resynchronization with the +# master if the replication link is lost for a relatively small amount of +# time. You may want to configure the replication backlog size (see the next +# sections of this file) with a sensible value depending on your needs. +# 3) Replication is automatic and does not need user intervention. After a +# network partition slaves automatically try to reconnect to masters +# and resynchronize with them. +# +# slaveof + +# If the master is password protected (using the "requirepass" configuration +# directive below) it is possible to tell the slave to authenticate before +# starting the replication synchronization process, otherwise the master will +# refuse the slave request. +# +# masterauth + +# When a slave loses its connection with the master, or when the replication +# is still in progress, the slave can act in two different ways: +# +# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will +# still reply to client requests, possibly with out of date data, or the +# data set may just be empty if this is the first synchronization. +# +# 2) if slave-serve-stale-data is set to 'no' the slave will reply with +# an error "SYNC with master in progress" to all the kind of commands +# but to INFO and SLAVEOF. +# +slave-serve-stale-data yes + +# You can configure a slave instance to accept writes or not. Writing against +# a slave instance may be useful to store some ephemeral data (because data +# written on a slave will be easily deleted after resync with the master) but +# may also cause problems if clients are writing to it because of a +# misconfiguration. +# +# Since Redis 2.6 by default slaves are read-only. +# +# Note: read only slaves are not designed to be exposed to untrusted clients +# on the internet. It's just a protection layer against misuse of the instance. +# Still a read only slave exports by default all the administrative commands +# such as CONFIG, DEBUG, and so forth. To a limited extent you can improve +# security of read only slaves using 'rename-command' to shadow all the +# administrative / dangerous commands. +slave-read-only yes + +# Replication SYNC strategy: disk or socket. +# +# ------------------------------------------------------- +# WARNING: DISKLESS REPLICATION IS EXPERIMENTAL CURRENTLY +# ------------------------------------------------------- +# +# New slaves and reconnecting slaves that are not able to continue the replication +# process just receiving differences, need to do what is called a "full +# synchronization". An RDB file is transmitted from the master to the slaves. +# The transmission can happen in two different ways: +# +# 1) Disk-backed: The Redis master creates a new process that writes the RDB +# file on disk. Later the file is transferred by the parent +# process to the slaves incrementally. +# 2) Diskless: The Redis master creates a new process that directly writes the +# RDB file to slave sockets, without touching the disk at all. +# +# With disk-backed replication, while the RDB file is generated, more slaves +# can be queued and served with the RDB file as soon as the current child producing +# the RDB file finishes its work. With diskless replication instead once +# the transfer starts, new slaves arriving will be queued and a new transfer +# will start when the current one terminates. +# +# When diskless replication is used, the master waits a configurable amount of +# time (in seconds) before starting the transfer in the hope that multiple slaves +# will arrive and the transfer can be parallelized. +# +# With slow disks and fast (large bandwidth) networks, diskless replication +# works better. +repl-diskless-sync no + +# When diskless replication is enabled, it is possible to configure the delay +# the server waits in order to spawn the child that transfers the RDB via socket +# to the slaves. +# +# This is important since once the transfer starts, it is not possible to serve +# new slaves arriving, that will be queued for the next RDB transfer, so the server +# waits a delay in order to let more slaves arrive. +# +# The delay is specified in seconds, and by default is 5 seconds. To disable +# it entirely just set it to 0 seconds and the transfer will start ASAP. +repl-diskless-sync-delay 5 + +# Slaves send PINGs to server in a predefined interval. It's possible to change +# this interval with the repl_ping_slave_period option. The default value is 10 +# seconds. +# +# repl-ping-slave-period 10 + +# The following option sets the replication timeout for: +# +# 1) Bulk transfer I/O during SYNC, from the point of view of slave. +# 2) Master timeout from the point of view of slaves (data, pings). +# 3) Slave timeout from the point of view of masters (REPLCONF ACK pings). +# +# It is important to make sure that this value is greater than the value +# specified for repl-ping-slave-period otherwise a timeout will be detected +# every time there is low traffic between the master and the slave. +# +# repl-timeout 60 + +# Disable TCP_NODELAY on the slave socket after SYNC? +# +# If you select "yes" Redis will use a smaller number of TCP packets and +# less bandwidth to send data to slaves. But this can add a delay for +# the data to appear on the slave side, up to 40 milliseconds with +# Linux kernels using a default configuration. +# +# If you select "no" the delay for data to appear on the slave side will +# be reduced but more bandwidth will be used for replication. +# +# By default we optimize for low latency, but in very high traffic conditions +# or when the master and slaves are many hops away, turning this to "yes" may +# be a good idea. +repl-disable-tcp-nodelay no + +# Set the replication backlog size. The backlog is a buffer that accumulates +# slave data when slaves are disconnected for some time, so that when a slave +# wants to reconnect again, often a full resync is not needed, but a partial +# resync is enough, just passing the portion of data the slave missed while +# disconnected. +# +# The bigger the replication backlog, the longer the time the slave can be +# disconnected and later be able to perform a partial resynchronization. +# +# The backlog is only allocated once there is at least a slave connected. +# +# repl-backlog-size 1mb + +# After a master has no longer connected slaves for some time, the backlog +# will be freed. The following option configures the amount of seconds that +# need to elapse, starting from the time the last slave disconnected, for +# the backlog buffer to be freed. +# +# A value of 0 means to never release the backlog. +# +# repl-backlog-ttl 3600 + +# The slave priority is an integer number published by Redis in the INFO output. +# It is used by Redis Sentinel in order to select a slave to promote into a +# master if the master is no longer working correctly. +# +# A slave with a low priority number is considered better for promotion, so +# for instance if there are three slaves with priority 10, 100, 25 Sentinel will +# pick the one with priority 10, that is the lowest. +# +# However a special priority of 0 marks the slave as not able to perform the +# role of master, so a slave with priority of 0 will never be selected by +# Redis Sentinel for promotion. +# +# By default the priority is 100. +slave-priority 100 + +# It is possible for a master to stop accepting writes if there are less than +# N slaves connected, having a lag less or equal than M seconds. +# +# The N slaves need to be in "online" state. +# +# The lag in seconds, that must be <= the specified value, is calculated from +# the last ping received from the slave, that is usually sent every second. +# +# This option does not GUARANTEE that N replicas will accept the write, but +# will limit the window of exposure for lost writes in case not enough slaves +# are available, to the specified number of seconds. +# +# For example to require at least 3 slaves with a lag <= 10 seconds use: +# +# min-slaves-to-write 3 +# min-slaves-max-lag 10 +# +# Setting one or the other to 0 disables the feature. +# +# By default min-slaves-to-write is set to 0 (feature disabled) and +# min-slaves-max-lag is set to 10. + +################################## SECURITY ################################### + +# Require clients to issue AUTH before processing any other +# commands. This might be useful in environments in which you do not trust +# others with access to the host running redis-server. +# +# This should stay commented out for backward compatibility and because most +# people do not need auth (e.g. they run their own servers). +# +# Warning: since Redis is pretty fast an outside user can try up to +# 150k passwords per second against a good box. This means that you should +# use a very strong password otherwise it will be very easy to break. +# +# requirepass foobared + +# Command renaming. +# +# It is possible to change the name of dangerous commands in a shared +# environment. For instance the CONFIG command may be renamed into something +# hard to guess so that it will still be available for internal-use tools +# but not available for general clients. +# +# Example: +# +# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52 +# +# It is also possible to completely kill a command by renaming it into +# an empty string: +# +# rename-command CONFIG "" +# +# Please note that changing the name of commands that are logged into the +# AOF file or transmitted to slaves may cause problems. + +################################### LIMITS #################################### + +# Set the max number of connected clients at the same time. By default +# this limit is set to 10000 clients, however if the Redis server is not +# able to configure the process file limit to allow for the specified limit +# the max number of allowed clients is set to the current file limit +# minus 32 (as Redis reserves a few file descriptors for internal uses). +# +# Once the limit is reached Redis will close all the new connections sending +# an error 'max number of clients reached'. +# +# maxclients 10000 + +# Don't use more memory than the specified amount of bytes. +# When the memory limit is reached Redis will try to remove keys +# according to the eviction policy selected (see maxmemory-policy). +# +# If Redis can't remove keys according to the policy, or if the policy is +# set to 'noeviction', Redis will start to reply with errors to commands +# that would use more memory, like SET, LPUSH, and so on, and will continue +# to reply to read-only commands like GET. +# +# This option is usually useful when using Redis as an LRU cache, or to set +# a hard memory limit for an instance (using the 'noeviction' policy). +# +# WARNING: If you have slaves attached to an instance with maxmemory on, +# the size of the output buffers needed to feed the slaves are subtracted +# from the used memory count, so that network problems / resyncs will +# not trigger a loop where keys are evicted, and in turn the output +# buffer of slaves is full with DELs of keys evicted triggering the deletion +# of more keys, and so forth until the database is completely emptied. +# +# In short... if you have slaves attached it is suggested that you set a lower +# limit for maxmemory so that there is some free RAM on the system for slave +# output buffers (but this is not needed if the policy is 'noeviction'). +# +# maxmemory + +# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory +# is reached. You can select among five behaviors: +# +# volatile-lru -> remove the key with an expire set using an LRU algorithm +# allkeys-lru -> remove any key according to the LRU algorithm +# volatile-random -> remove a random key with an expire set +# allkeys-random -> remove a random key, any key +# volatile-ttl -> remove the key with the nearest expire time (minor TTL) +# noeviction -> don't expire at all, just return an error on write operations +# +# Note: with any of the above policies, Redis will return an error on write +# operations, when there are no suitable keys for eviction. +# +# At the date of writing these commands are: set setnx setex append +# incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd +# sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby +# zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby +# getset mset msetnx exec sort +# +# The default is: +# +# maxmemory-policy noeviction + +# LRU and minimal TTL algorithms are not precise algorithms but approximated +# algorithms (in order to save memory), so you can tune it for speed or +# accuracy. For default Redis will check five keys and pick the one that was +# used less recently, you can change the sample size using the following +# configuration directive. +# +# The default of 5 produces good enough results. 10 Approximates very closely +# true LRU but costs a bit more CPU. 3 is very fast but not very accurate. +# +# maxmemory-samples 5 + +############################## APPEND ONLY MODE ############################### + +# By default Redis asynchronously dumps the dataset on disk. This mode is +# good enough in many applications, but an issue with the Redis process or +# a power outage may result into a few minutes of writes lost (depending on +# the configured save points). +# +# The Append Only File is an alternative persistence mode that provides +# much better durability. For instance using the default data fsync policy +# (see later in the config file) Redis can lose just one second of writes in a +# dramatic event like a server power outage, or a single write if something +# wrong with the Redis process itself happens, but the operating system is +# still running correctly. +# +# AOF and RDB persistence can be enabled at the same time without problems. +# If the AOF is enabled on startup Redis will load the AOF, that is the file +# with the better durability guarantees. +# +# Please check http://redis.io/topics/persistence for more information. + +appendonly no + +# The name of the append only file (default: "appendonly.aof") + +appendfilename "appendonly.aof" + +# The fsync() call tells the Operating System to actually write data on disk +# instead of waiting for more data in the output buffer. Some OS will really flush +# data on disk, some other OS will just try to do it ASAP. +# +# Redis supports three different modes: +# +# no: don't fsync, just let the OS flush the data when it wants. Faster. +# always: fsync after every write to the append only log. Slow, Safest. +# everysec: fsync only one time every second. Compromise. +# +# The default is "everysec", as that's usually the right compromise between +# speed and data safety. It's up to you to understand if you can relax this to +# "no" that will let the operating system flush the output buffer when +# it wants, for better performances (but if you can live with the idea of +# some data loss consider the default persistence mode that's snapshotting), +# or on the contrary, use "always" that's very slow but a bit safer than +# everysec. +# +# More details please check the following article: +# http://antirez.com/post/redis-persistence-demystified.html +# +# If unsure, use "everysec". + +# appendfsync always +appendfsync everysec +# appendfsync no + +# When the AOF fsync policy is set to always or everysec, and a background +# saving process (a background save or AOF log background rewriting) is +# performing a lot of I/O against the disk, in some Linux configurations +# Redis may block too long on the fsync() call. Note that there is no fix for +# this currently, as even performing fsync in a different thread will block +# our synchronous write(2) call. +# +# In order to mitigate this problem it's possible to use the following option +# that will prevent fsync() from being called in the main process while a +# BGSAVE or BGREWRITEAOF is in progress. +# +# This means that while another child is saving, the durability of Redis is +# the same as "appendfsync none". In practical terms, this means that it is +# possible to lose up to 30 seconds of log in the worst scenario (with the +# default Linux settings). +# +# If you have latency problems turn this to "yes". Otherwise leave it as +# "no" that is the safest pick from the point of view of durability. + +no-appendfsync-on-rewrite no + +# Automatic rewrite of the append only file. +# Redis is able to automatically rewrite the log file implicitly calling +# BGREWRITEAOF when the AOF log size grows by the specified percentage. +# +# This is how it works: Redis remembers the size of the AOF file after the +# latest rewrite (if no rewrite has happened since the restart, the size of +# the AOF at startup is used). +# +# This base size is compared to the current size. If the current size is +# bigger than the specified percentage, the rewrite is triggered. Also +# you need to specify a minimal size for the AOF file to be rewritten, this +# is useful to avoid rewriting the AOF file even if the percentage increase +# is reached but it is still pretty small. +# +# Specify a percentage of zero in order to disable the automatic AOF +# rewrite feature. + +auto-aof-rewrite-percentage 100 +auto-aof-rewrite-min-size 64mb + +# An AOF file may be found to be truncated at the end during the Redis +# startup process, when the AOF data gets loaded back into memory. +# This may happen when the system where Redis is running +# crashes, especially when an ext4 filesystem is mounted without the +# data=ordered option (however this can't happen when Redis itself +# crashes or aborts but the operating system still works correctly). +# +# Redis can either exit with an error when this happens, or load as much +# data as possible (the default now) and start if the AOF file is found +# to be truncated at the end. The following option controls this behavior. +# +# If aof-load-truncated is set to yes, a truncated AOF file is loaded and +# the Redis server starts emitting a log to inform the user of the event. +# Otherwise if the option is set to no, the server aborts with an error +# and refuses to start. When the option is set to no, the user requires +# to fix the AOF file using the "redis-check-aof" utility before to restart +# the server. +# +# Note that if the AOF file will be found to be corrupted in the middle +# the server will still exit with an error. This option only applies when +# Redis will try to read more data from the AOF file but not enough bytes +# will be found. +aof-load-truncated yes + +################################ LUA SCRIPTING ############################### + +# Max execution time of a Lua script in milliseconds. +# +# If the maximum execution time is reached Redis will log that a script is +# still in execution after the maximum allowed time and will start to +# reply to queries with an error. +# +# When a long running script exceeds the maximum execution time only the +# SCRIPT KILL and SHUTDOWN NOSAVE commands are available. The first can be +# used to stop a script that did not yet called write commands. The second +# is the only way to shut down the server in the case a write command was +# already issued by the script but the user doesn't want to wait for the natural +# termination of the script. +# +# Set it to 0 or a negative value for unlimited execution without warnings. +lua-time-limit 5000 + +################################ REDIS CLUSTER ############################### +# +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# WARNING EXPERIMENTAL: Redis Cluster is considered to be stable code, however +# in order to mark it as "mature" we need to wait for a non trivial percentage +# of users to deploy it in production. +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# +# Normal Redis instances can't be part of a Redis Cluster; only nodes that are +# started as cluster nodes can. In order to start a Redis instance as a +# cluster node enable the cluster support uncommenting the following: +# +# cluster-enabled yes + +# Every cluster node has a cluster configuration file. This file is not +# intended to be edited by hand. It is created and updated by Redis nodes. +# Every Redis Cluster node requires a different cluster configuration file. +# Make sure that instances running in the same system do not have +# overlapping cluster configuration file names. +# +# cluster-config-file nodes-6379.conf + +# Cluster node timeout is the amount of milliseconds a node must be unreachable +# for it to be considered in failure state. +# Most other internal time limits are multiple of the node timeout. +# +# cluster-node-timeout 15000 + +# A slave of a failing master will avoid to start a failover if its data +# looks too old. +# +# There is no simple way for a slave to actually have a exact measure of +# its "data age", so the following two checks are performed: +# +# 1) If there are multiple slaves able to failover, they exchange messages +# in order to try to give an advantage to the slave with the best +# replication offset (more data from the master processed). +# Slaves will try to get their rank by offset, and apply to the start +# of the failover a delay proportional to their rank. +# +# 2) Every single slave computes the time of the last interaction with +# its master. This can be the last ping or command received (if the master +# is still in the "connected" state), or the time that elapsed since the +# disconnection with the master (if the replication link is currently down). +# If the last interaction is too old, the slave will not try to failover +# at all. +# +# The point "2" can be tuned by user. Specifically a slave will not perform +# the failover if, since the last interaction with the master, the time +# elapsed is greater than: +# +# (node-timeout * slave-validity-factor) + repl-ping-slave-period +# +# So for example if node-timeout is 30 seconds, and the slave-validity-factor +# is 10, and assuming a default repl-ping-slave-period of 10 seconds, the +# slave will not try to failover if it was not able to talk with the master +# for longer than 310 seconds. +# +# A large slave-validity-factor may allow slaves with too old data to failover +# a master, while a too small value may prevent the cluster from being able to +# elect a slave at all. +# +# For maximum availability, it is possible to set the slave-validity-factor +# to a value of 0, which means, that slaves will always try to failover the +# master regardless of the last time they interacted with the master. +# (However they'll always try to apply a delay proportional to their +# offset rank). +# +# Zero is the only value able to guarantee that when all the partitions heal +# the cluster will always be able to continue. +# +# cluster-slave-validity-factor 10 + +# Cluster slaves are able to migrate to orphaned masters, that are masters +# that are left without working slaves. This improves the cluster ability +# to resist to failures as otherwise an orphaned master can't be failed over +# in case of failure if it has no working slaves. +# +# Slaves migrate to orphaned masters only if there are still at least a +# given number of other working slaves for their old master. This number +# is the "migration barrier". A migration barrier of 1 means that a slave +# will migrate only if there is at least 1 other working slave for its master +# and so forth. It usually reflects the number of slaves you want for every +# master in your cluster. +# +# Default is 1 (slaves migrate only if their masters remain with at least +# one slave). To disable migration just set it to a very large value. +# A value of 0 can be set but is useful only for debugging and dangerous +# in production. +# +# cluster-migration-barrier 1 + +# By default Redis Cluster nodes stop accepting queries if they detect there +# is at least an hash slot uncovered (no available node is serving it). +# This way if the cluster is partially down (for example a range of hash slots +# are no longer covered) all the cluster becomes, eventually, unavailable. +# It automatically returns available as soon as all the slots are covered again. +# +# However sometimes you want the subset of the cluster which is working, +# to continue to accept queries for the part of the key space that is still +# covered. In order to do so, just set the cluster-require-full-coverage +# option to no. +# +# cluster-require-full-coverage yes + +# In order to setup your cluster make sure to read the documentation +# available at http://redis.io web site. + +################################## SLOW LOG ################################### + +# The Redis Slow Log is a system to log queries that exceeded a specified +# execution time. The execution time does not include the I/O operations +# like talking with the client, sending the reply and so forth, +# but just the time needed to actually execute the command (this is the only +# stage of command execution where the thread is blocked and can not serve +# other requests in the meantime). +# +# You can configure the slow log with two parameters: one tells Redis +# what is the execution time, in microseconds, to exceed in order for the +# command to get logged, and the other parameter is the length of the +# slow log. When a new command is logged the oldest one is removed from the +# queue of logged commands. + +# The following time is expressed in microseconds, so 1000000 is equivalent +# to one second. Note that a negative number disables the slow log, while +# a value of zero forces the logging of every command. +slowlog-log-slower-than 10000 + +# There is no limit to this length. Just be aware that it will consume memory. +# You can reclaim memory used by the slow log with SLOWLOG RESET. +slowlog-max-len 128 + +################################ LATENCY MONITOR ############################## + +# The Redis latency monitoring subsystem samples different operations +# at runtime in order to collect data related to possible sources of +# latency of a Redis instance. +# +# Via the LATENCY command this information is available to the user that can +# print graphs and obtain reports. +# +# The system only logs operations that were performed in a time equal or +# greater than the amount of milliseconds specified via the +# latency-monitor-threshold configuration directive. When its value is set +# to zero, the latency monitor is turned off. +# +# By default latency monitoring is disabled since it is mostly not needed +# if you don't have latency issues, and collecting data has a performance +# impact, that while very small, can be measured under big load. Latency +# monitoring can easily be enabled at runtime using the command +# "CONFIG SET latency-monitor-threshold " if needed. +latency-monitor-threshold 0 + +############################# EVENT NOTIFICATION ############################## + +# Redis can notify Pub/Sub clients about events happening in the key space. +# This feature is documented at http://redis.io/topics/notifications +# +# For instance if keyspace events notification is enabled, and a client +# performs a DEL operation on key "foo" stored in the Database 0, two +# messages will be published via Pub/Sub: +# +# PUBLISH __keyspace@0__:foo del +# PUBLISH __keyevent@0__:del foo +# +# It is possible to select the events that Redis will notify among a set +# of classes. Every class is identified by a single character: +# +# K Keyspace events, published with __keyspace@__ prefix. +# E Keyevent events, published with __keyevent@__ prefix. +# g Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ... +# $ String commands +# l List commands +# s Set commands +# h Hash commands +# z Sorted set commands +# x Expired events (events generated every time a key expires) +# e Evicted events (events generated when a key is evicted for maxmemory) +# A Alias for g$lshzxe, so that the "AKE" string means all the events. +# +# The "notify-keyspace-events" takes as argument a string that is composed +# of zero or multiple characters. The empty string means that notifications +# are disabled. +# +# Example: to enable list and generic events, from the point of view of the +# event name, use: +# +# notify-keyspace-events Elg +# +# Example 2: to get the stream of the expired keys subscribing to channel +# name __keyevent@0__:expired use: +# +# notify-keyspace-events Ex +# +# By default all notifications are disabled because most users don't need +# this feature and the feature has some overhead. Note that if you don't +# specify at least one of K or E, no events will be delivered. +notify-keyspace-events "" + +############################### ADVANCED CONFIG ############################### + +# Hashes are encoded using a memory efficient data structure when they have a +# small number of entries, and the biggest entry does not exceed a given +# threshold. These thresholds can be configured using the following directives. +hash-max-ziplist-entries 512 +hash-max-ziplist-value 64 + +# Lists are also encoded in a special way to save a lot of space. +# The number of entries allowed per internal list node can be specified +# as a fixed maximum size or a maximum number of elements. +# For a fixed maximum size, use -5 through -1, meaning: +# -5: max size: 64 Kb <-- not recommended for normal workloads +# -4: max size: 32 Kb <-- not recommended +# -3: max size: 16 Kb <-- probably not recommended +# -2: max size: 8 Kb <-- good +# -1: max size: 4 Kb <-- good +# Positive numbers mean store up to _exactly_ that number of elements +# per list node. +# The highest performing option is usually -2 (8 Kb size) or -1 (4 Kb size), +# but if your use case is unique, adjust the settings as necessary. +list-max-ziplist-size -2 + +# Lists may also be compressed. +# Compress depth is the number of quicklist ziplist nodes from *each* side of +# the list to *exclude* from compression. The head and tail of the list +# are always uncompressed for fast push/pop operations. Settings are: +# 0: disable all list compression +# 1: depth 1 means "don't start compressing until after 1 node into the list, +# going from either the head or tail" +# So: [head]->node->node->...->node->[tail] +# [head], [tail] will always be uncompressed; inner nodes will compress. +# 2: [head]->[next]->node->node->...->node->[prev]->[tail] +# 2 here means: don't compress head or head->next or tail->prev or tail, +# but compress all nodes between them. +# 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail] +# etc. +list-compress-depth 0 + +# Sets have a special encoding in just one case: when a set is composed +# of just strings that happen to be integers in radix 10 in the range +# of 64 bit signed integers. +# The following configuration setting sets the limit in the size of the +# set in order to use this special memory saving encoding. +set-max-intset-entries 512 + +# Similarly to hashes and lists, sorted sets are also specially encoded in +# order to save a lot of space. This encoding is only used when the length and +# elements of a sorted set are below the following limits: +zset-max-ziplist-entries 128 +zset-max-ziplist-value 64 + +# HyperLogLog sparse representation bytes limit. The limit includes the +# 16 bytes header. When an HyperLogLog using the sparse representation crosses +# this limit, it is converted into the dense representation. +# +# A value greater than 16000 is totally useless, since at that point the +# dense representation is more memory efficient. +# +# The suggested value is ~ 3000 in order to have the benefits of +# the space efficient encoding without slowing down too much PFADD, +# which is O(N) with the sparse encoding. The value can be raised to +# ~ 10000 when CPU is not a concern, but space is, and the data set is +# composed of many HyperLogLogs with cardinality in the 0 - 15000 range. +hll-sparse-max-bytes 3000 + +# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in +# order to help rehashing the main Redis hash table (the one mapping top-level +# keys to values). The hash table implementation Redis uses (see dict.c) +# performs a lazy rehashing: the more operation you run into a hash table +# that is rehashing, the more rehashing "steps" are performed, so if the +# server is idle the rehashing is never complete and some more memory is used +# by the hash table. +# +# The default is to use this millisecond 10 times every second in order to +# actively rehash the main dictionaries, freeing memory when possible. +# +# If unsure: +# use "activerehashing no" if you have hard latency requirements and it is +# not a good thing in your environment that Redis can reply from time to time +# to queries with 2 milliseconds delay. +# +# use "activerehashing yes" if you don't have such hard requirements but +# want to free memory asap when possible. +activerehashing yes + +# The client output buffer limits can be used to force disconnection of clients +# that are not reading data from the server fast enough for some reason (a +# common reason is that a Pub/Sub client can't consume messages as fast as the +# publisher can produce them). +# +# The limit can be set differently for the three different classes of clients: +# +# normal -> normal clients including MONITOR clients +# slave -> slave clients +# pubsub -> clients subscribed to at least one pubsub channel or pattern +# +# The syntax of every client-output-buffer-limit directive is the following: +# +# client-output-buffer-limit +# +# A client is immediately disconnected once the hard limit is reached, or if +# the soft limit is reached and remains reached for the specified number of +# seconds (continuously). +# So for instance if the hard limit is 32 megabytes and the soft limit is +# 16 megabytes / 10 seconds, the client will get disconnected immediately +# if the size of the output buffers reach 32 megabytes, but will also get +# disconnected if the client reaches 16 megabytes and continuously overcomes +# the limit for 10 seconds. +# +# By default normal clients are not limited because they don't receive data +# without asking (in a push way), but just after a request, so only +# asynchronous clients may create a scenario where data is requested faster +# than it can read. +# +# Instead there is a default limit for pubsub and slave clients, since +# subscribers and slaves receive data in a push fashion. +# +# Both the hard or the soft limit can be disabled by setting them to zero. +client-output-buffer-limit normal 0 0 0 +client-output-buffer-limit slave 256mb 64mb 60 +client-output-buffer-limit pubsub 32mb 8mb 60 + +# Redis calls an internal function to perform many background tasks, like +# closing connections of clients in timeout, purging expired keys that are +# never requested, and so forth. +# +# Not all tasks are performed with the same frequency, but Redis checks for +# tasks to perform according to the specified "hz" value. +# +# By default "hz" is set to 10. Raising the value will use more CPU when +# Redis is idle, but at the same time will make Redis more responsive when +# there are many keys expiring at the same time, and timeouts may be +# handled with more precision. +# +# The range is between 1 and 500, however a value over 100 is usually not +# a good idea. Most users should use the default of 10 and raise this up to +# 100 only in environments where very low latency is required. +hz 10 + +# When a child rewrites the AOF file, if the following option is enabled +# the file will be fsync-ed every 32 MB of data generated. This is useful +# in order to commit the file to the disk more incrementally and avoid +# big latency spikes. +aof-rewrite-incremental-fsync yes diff --git a/hash.php b/hash.php deleted file mode 100644 index 733281d..0000000 --- a/hash.php +++ /dev/null @@ -1,19 +0,0 @@ -. - */ - -use Sikofitt\App\Controller\RsvpControllerProvider; -use Sikofitt\App\Controller\UserController; -use Sikofitt\App\Middleware\CspMiddleware; -use Sikofitt\App\Middleware\HeaderMiddleware; - -$loader = require __DIR__.'/../vendor/autoload.php'; - -$app = new Kernel($loader, true); -// Controllers -// Default - -$app->mount('/rsvp', new RsvpControllerProvider()); - -$app->mount('/user', new UserController()); - - //->before(new MysqlAuthenticatorMiddleware()); -// Middleware -$app->before(new CspMiddleware(), \Kernel::EARLY_EVENT); - -$app->before(new HeaderMiddleware(), \Kernel::EARLY_EVENT); -// Run the app - -$app->run(); diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..65e9082 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,31 @@ + + + + + + + + + + + + tests + + + + + + src + + src/*Bundle/Resources + src/*/*Bundle/Resources + src/*/Bundle/*Bundle/Resources + + + + diff --git a/src/.htaccess b/src/.htaccess new file mode 100644 index 0000000..fb1de45 --- /dev/null +++ b/src/.htaccess @@ -0,0 +1,7 @@ + + Require all denied + + + Order deny,allow + Deny from all + diff --git a/src/Sikofitt/App/Configuration/DatabaseConfiguration.php b/src/Sikofitt/App/Configuration/DatabaseConfiguration.php deleted file mode 100644 index e7027ca..0000000 --- a/src/Sikofitt/App/Configuration/DatabaseConfiguration.php +++ /dev/null @@ -1,96 +0,0 @@ -. - */ - -namespace Sikofitt\App\Configuration; - -use Symfony\Component\Config\Definition\Builder\TreeBuilder; -use Symfony\Component\Config\Definition\ConfigurationInterface; - -class DatabaseConfiguration implements ConfigurationInterface -{ - public function getConfigTreeBuilder() - { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('doughnut'); - - $rootNode->children() - ->arrayNode('connections') - ->prototype('array') - ->children() - ->arrayNode('connection') - ->children() - ->scalarNode('driver') - ->isRequired() - ->validate() - ->ifNotInArray(['pdo_mysql', 'pdo_pgsql', 'pdo_sqlite']) - ->thenInvalid('Invalid driver : %s') - ->end() // ifNotInArray - ->end() // driver - ->scalarNode('dbname')->isRequired()->end() // database - ->scalarNode('host')->defaultValue('127.0.0.1')->end() - ->scalarNode('user')->isRequired()->end() - ->scalarNode('password')->isRequired()->end() - ->end() // connection.prototype - ->end() // connection - ->arrayNode('annotation_autoloaders') - ->requiresAtLeastOneElement() - ->prototype('scalar') - ->isRequired() - ->end() - ->end() - ->arrayNode('metadata_mapping') - ->prototype('array') - ->children() - ->arrayNode('path') - ->requiresAtLeastOneElement() - ->prototype('scalar') - ->isRequired() - ->end() - ->end() - ->scalarNode('type') - ->isRequired() - ->beforeNormalization() - ->ifString() - ->then(function ($s) { - return $this->normalizeConstant($s); - }) - ->end() - ->end() - ->end() - ->end() - ->end() - ->end(); - - return $treeBuilder; - } - - private function normalizeConstant($const) - { - $classParts = explode('::', $const); - if (isset($classParts[1])) { - $reflected = new \ReflectionClass($classParts[0]); - $constant = $reflected->getConstant($classParts[1]); - - return $constant; - } else { - return $const; - } - } -} diff --git a/src/Sikofitt/App/Middleware/AuthenticatorMiddleware.php b/src/Sikofitt/App/Middleware/AuthenticatorMiddleware.php deleted file mode 100644 index bcd45dd..0000000 --- a/src/Sikofitt/App/Middleware/AuthenticatorMiddleware.php +++ /dev/null @@ -1,33 +0,0 @@ -. - */ - -namespace Sikofitt\App\Middleware; - -use Symfony\Component\HttpFoundation\Request; - -class AuthenticatorMiddleware -{ - public function __invoke(Request $request, \Kernel $app) - { - if ($app->session()->has('user')) { - return true; - } - } -} diff --git a/src/Sikofitt/App/Middleware/CspMiddleware.php b/src/Sikofitt/App/Middleware/CspMiddleware.php deleted file mode 100644 index 7eb69f5..0000000 --- a/src/Sikofitt/App/Middleware/CspMiddleware.php +++ /dev/null @@ -1,56 +0,0 @@ -. - */ - -namespace Sikofitt\App\Middleware; - -use Monolog\Logger; -use ParagonIE\CSPBuilder\CSPBuilder; -use Symfony\Component\HttpFoundation\Request; - -/** - * Class CspMiddleware. - * - * Builds Content Security Policy (CSP) headers. - */ -class CspMiddleware -{ - public function __invoke(Request $request, \Kernel $app) - { - $cspDir = realpath($app->getConfigDir()); - if (false === file_exists($cspDir.'/csp.json')) { - $app->log( - sprintf('csp.json was not found in %s, skipping.', $cspDir), - [ - 'configured log dir' => realpath($cspDir), - ], - Logger::NOTICE - ); - - return; - } - $app->log('Setting Content Security Policy (CSP) headers.', - [ - 'class' => get_class($this), - ] - ); - $csp = CSPBuilder::fromFile($app->getBaseDir().'/app/config/csp.json'); - $csp->sendCSPHeader(); - } -} diff --git a/src/Sikofitt/App/Middleware/HeaderMiddleware.php b/src/Sikofitt/App/Middleware/HeaderMiddleware.php deleted file mode 100644 index b9893cd..0000000 --- a/src/Sikofitt/App/Middleware/HeaderMiddleware.php +++ /dev/null @@ -1,44 +0,0 @@ -. - */ - -namespace Sikofitt\App\Middleware; - -use Silex\Application; -use Symfony\Component\HttpFoundation\Request; - -/** - * Class HeaderMiddleware. - * - * Injects custom headers into the application. - */ -class HeaderMiddleware -{ - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Silex\Application $app - */ - public function __invoke(Request $request, Application $app) - { - $poweredByLine = sprintf('Silex/%s [%s] %s/%s', Application::VERSION, php_sapi_name(), php_uname('s'), php_uname('m')); - - header('X-Powered-By: '.$poweredByLine); - header('Server: Nginx/Unix ('.php_uname('m').')'); - } -} diff --git a/src/Sikofitt/App/Provider/DoctrineConsoleProvider.php b/src/Sikofitt/App/Provider/DoctrineConsoleProvider.php deleted file mode 100644 index 49d2303..0000000 --- a/src/Sikofitt/App/Provider/DoctrineConsoleProvider.php +++ /dev/null @@ -1,110 +0,0 @@ -. - */ - -namespace Sikofitt\App\Provider; - -use Doctrine\DBAL\Tools\Console\Command\{ - ImportCommand, - ReservedWordsCommand, - RunSqlCommand -}; -use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper; -use Doctrine\ORM\Tools\Console\Command\{ - ClearCache\EntityRegionCommand, ClearCache\MetadataCommand, - ClearCache\QueryCommand, ClearCache\ResultCommand, - ConvertDoctrine1SchemaCommand, ConvertMappingCommand, - EnsureProductionSettingsCommand, GenerateEntitiesCommand, - GenerateProxiesCommand, GenerateRepositoriesCommand, InfoCommand, - MappingDescribeCommand, RunDqlCommand, SchemaTool\CreateCommand, - SchemaTool\DropCommand, SchemaTool\UpdateCommand, ValidateSchemaCommand -}; -use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; -use Pimple\Container; -use Pimple\ServiceProviderInterface; -use Symfony\Component\Console\Helper\HelperSet; - -/** - * Class DoctrineConsoleProvider. - */ -class DoctrineConsoleProvider implements ServiceProviderInterface -{ - /** - * Registers services on the given container. - * - * This method should only be used to configure services and parameters. - * It should not get services. - * - * @param Container $pimple A container instance - * - * @throws \LogicException - */ - public function register(Container $pimple) - { - if (false === isset($pimple['console'])) { - throw new \LogicException('You must enable the Knp\Provider\ConsoleServiceProvider service provider to be able to use the DoctrineConsoleProvider.'); - } - if (false === isset($pimple['db.options'])) { - throw new \LogicException('You must enable the DoctrineServiceProvider to use the DoctrineConsoleProvider.'); - } - if (false === isset($pimple['orm.em'])) { - throw new \LogicException('You must enable the Dflydev\Provider\DoctrineOrm\DoctrineOrmServiceProvider to use the DoctrineConsoleProvider.'); - } - - $console = $pimple['console']; - $console->setHelperSet(new HelperSet([ - 'em' => new EntityManagerHelper($pimple['orm.em']), - 'db' => new ConnectionHelper($pimple['db']), - ])); - - $schemaUpdateCommand = (new UpdateCommand()) - ->setName('orm:schema:update'); - $schemaValidateCommand = (new ValidateSchemaCommand()) - ->setName('orm:schema:validate') - ->setAliases(['validate']); - $schemaDropCommand = (new DropCommand()) - ->setName('orm:schema:drop'); - $schemaCreateCommand = (new CreateCommand()) - ->setName('orm:schema:create'); - $queryCommand = new QueryCommand(); - - $console->addCommands([ - new ConvertDoctrine1SchemaCommand(), - new ConvertMappingCommand(), - new EnsureProductionSettingsCommand(), - new EntityRegionCommand(), - new GenerateEntitiesCommand(), - new GenerateProxiesCommand(), - new GenerateRepositoriesCommand(), - new ImportCommand(), - new InfoCommand(), - new MappingDescribeCommand(), - new MetadataCommand(), - new QueryCommand(), - new RunDqlCommand(), - new RunSqlCommand(), - new ReservedWordsCommand(), - new ResultCommand(), - $schemaCreateCommand, - $schemaDropCommand, - $schemaUpdateCommand, - $schemaValidateCommand, - ]); - } -} diff --git a/src/Sikofitt/App/Traits/EntityManagerTrait.php b/src/Sikofitt/App/Traits/EntityManagerTrait.php deleted file mode 100644 index 8148ee5..0000000 --- a/src/Sikofitt/App/Traits/EntityManagerTrait.php +++ /dev/null @@ -1,38 +0,0 @@ -. - */ - -namespace Sikofitt\App\Traits; - -use Doctrine\ORM\EntityManager; - -trait EntityManagerTrait -{ - /** - * @return null|EntityManager - */ - public function getEntityManager() - { - if (false === isset($this['orm.em']) || false === isset($this['db.options'])) { - return null; - } - - return $this['orm.em']; - } -} diff --git a/src/Sikofitt/App/Traits/FlashTrait.php b/src/Sikofitt/App/Traits/FlashTrait.php deleted file mode 100644 index 532fa68..0000000 --- a/src/Sikofitt/App/Traits/FlashTrait.php +++ /dev/null @@ -1,190 +0,0 @@ -. - */ - -namespace Sikofitt\App\Traits; - -use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; -use Symfony\Component\HttpFoundation\Session\Session; - -/** - * Trait FlashTrait. - * - * Adds shortcuts for adding flash messages. - */ -trait FlashTrait -{ - /** - * @param \string[] ...$messages - * - * @return $this|null - */ - public function addInfo(string ...$messages) - { - if (false === isset($this['session'])) { - return null; - } - - foreach ($messages as $message) { - $this['session']->getFlashBag()->add('info', $message); - } - - return $this; - } - - /** - * @param \string[] ...$messages - * - * @return $this - */ - public function addError(string ...$messages) - { - if (false === isset($this['session'])) { - return null; - } - - foreach ($messages as $message) { - $this['session']->getFlashBag()->add('error', $message); - } - - return $this; - } - - /** - * @param \string[] ...$messages - * - * @return $this - */ - public function addSuccess(string ...$messages) - { - if (false === isset($this['session'])) { - return null; - } - - foreach ($messages as $message) { - $this['session']->getFlashBag()->add('success', $message); - } - - return $this; - } - - public function addWarning(string ...$messages) - { - if (false === isset($this['session'])) { - return null; - } - - foreach ($messages as $message) { - $this['session']->getFlashBag()->add('warning', $message); - } - - return $this; - } - - /** - * @return array|null - */ - public function peekAll() - { - if (false === isset($this['session'])) { - return null; - } - - return $this['session']->getFlashBag()->peekAll(); - } - - /** - * @param string $name - * @param array $default - * - * @return array|null - */ - public function peekFlash(string $name, array $default = []) - { - if (false === isset($this['session'])) { - return null; - } - - if (true === $this['session']->getFlashBag()->has($name)) { - return $this['session']->getFlashBag()->peek($name, $default); - } - - return []; - } - - public function clearFlashes() - { - $this['session']->getFlashBag()->clear(); - } - - /** - * @param string $name - * @param array $default - * - * @return array - */ - public function getFlash(string $name, array $default = []) - { - if (false === isset($this['session'])) { - return null; - } - - if (true === $this['session']->getFlashBag()->has($name)) { - return $this['session']->getFlashBag()->get($name, $default); - } - - return []; - } - - /** - * @return FlashBag - */ - public function getFlashBag() - { - if (false === isset($this['session'])) { - return null; - } - - return $this['session']->getFlashBag(); - } - - /** - * @return Session - */ - public function session() - { - if (false === isset($this['session'])) { - if (class_exists(Session::class)) { - return new Session(); - } else { - return null; - } - } - - return $this['session']; - } - - /** - * @return Session - */ - public function getSession() - { - return $this->session(); - } -} diff --git a/src/Sikofitt/App/Controller/DefaultController.php b/src/Sikofitt/DoughnutWeddingBundle/Controller/DefaultController.php similarity index 95% rename from src/Sikofitt/App/Controller/DefaultController.php rename to src/Sikofitt/DoughnutWeddingBundle/Controller/DefaultController.php index 37daf37..4704809 100644 --- a/src/Sikofitt/App/Controller/DefaultController.php +++ b/src/Sikofitt/DoughnutWeddingBundle/Controller/DefaultController.php @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -namespace Sikofitt\App\Controller; +namespace Sikofitt\DoughnutWeddingBundle\Controller; use Symfony\Component\HttpFoundation\Request; diff --git a/src/Sikofitt/App/Controller/RouterCollector.php b/src/Sikofitt/DoughnutWeddingBundle/Controller/RouterCollector.php similarity index 95% rename from src/Sikofitt/App/Controller/RouterCollector.php rename to src/Sikofitt/DoughnutWeddingBundle/Controller/RouterCollector.php index 2c53fd6..f1da3b2 100644 --- a/src/Sikofitt/App/Controller/RouterCollector.php +++ b/src/Sikofitt/DoughnutWeddingBundle/Controller/RouterCollector.php @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -namespace Sikofitt\App\Controller; +namespace Sikofitt\DoughnutWeddingBundle\Controller; class RouterCollector { diff --git a/src/Sikofitt/App/Controller/RsvpController.php b/src/Sikofitt/DoughnutWeddingBundle/Controller/RsvpController.php similarity index 99% rename from src/Sikofitt/App/Controller/RsvpController.php rename to src/Sikofitt/DoughnutWeddingBundle/Controller/RsvpController.php index ff7112e..a43658e 100644 --- a/src/Sikofitt/App/Controller/RsvpController.php +++ b/src/Sikofitt/DoughnutWeddingBundle/Controller/RsvpController.php @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -namespace Sikofitt\App\Controller; +namespace Sikofitt\DoughnutWeddingBundle\Controller; use Doctrine\ORM\EntityManager; use Sikofitt\{ diff --git a/src/Sikofitt/App/Controller/UserController.php b/src/Sikofitt/DoughnutWeddingBundle/Controller/UserController.php similarity index 99% rename from src/Sikofitt/App/Controller/UserController.php rename to src/Sikofitt/DoughnutWeddingBundle/Controller/UserController.php index 7199d5d..debfe7a 100644 --- a/src/Sikofitt/App/Controller/UserController.php +++ b/src/Sikofitt/DoughnutWeddingBundle/Controller/UserController.php @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -namespace Sikofitt\App\Controller; +namespace Sikofitt\DoughnutWeddingBundle\Controller; use Sikofitt\App\Form\UserLoginType; use Sikofitt\App\Form\UserTokenType; diff --git a/src/Sikofitt/DoughnutWeddingBundle/DependencyInjection/Configuration.php b/src/Sikofitt/DoughnutWeddingBundle/DependencyInjection/Configuration.php new file mode 100644 index 0000000..18ca6e1 --- /dev/null +++ b/src/Sikofitt/DoughnutWeddingBundle/DependencyInjection/Configuration.php @@ -0,0 +1,29 @@ +root('sikofitt_doughnut_wedding'); + + // Here you should define the parameters that are allowed to + // configure your bundle. See the documentation linked above for + // more information on that topic. + + return $treeBuilder; + } +} diff --git a/src/Sikofitt/DoughnutWeddingBundle/DependencyInjection/SikofittDoughnutWeddingExtension.php b/src/Sikofitt/DoughnutWeddingBundle/DependencyInjection/SikofittDoughnutWeddingExtension.php new file mode 100644 index 0000000..c3e936f --- /dev/null +++ b/src/Sikofitt/DoughnutWeddingBundle/DependencyInjection/SikofittDoughnutWeddingExtension.php @@ -0,0 +1,28 @@ +processConfiguration($configuration, $configs); + + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.yml'); + } +} diff --git a/src/Sikofitt/App/Entity/Rsvp.php b/src/Sikofitt/DoughnutWeddingBundle/Entity/Rsvp.php similarity index 93% rename from src/Sikofitt/App/Entity/Rsvp.php rename to src/Sikofitt/DoughnutWeddingBundle/Entity/Rsvp.php index 2516d1e..eb860b9 100644 --- a/src/Sikofitt/App/Entity/Rsvp.php +++ b/src/Sikofitt/DoughnutWeddingBundle/Entity/Rsvp.php @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -namespace Sikofitt\App\Entity; +namespace Sikofitt\DoughnutWeddingBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; @@ -27,7 +27,7 @@ use Symfony\Component\Validator\Constraints as Assert; * Class Rsvp. * * @ORM\Table(name="rsvps") - * @ORM\Entity(repositoryClass="Sikofitt\App\Repository\RsvpRepository") + * @ORM\Entity(repositoryClass="Sikofitt\DoughnutWeddingBundle\Repository\RsvpRepository") */ class Rsvp { @@ -43,7 +43,7 @@ class Rsvp /** * @var int - * @ORM\OneToOne(targetEntity="Sikofitt\App\Entity\User", mappedBy="rsvp", cascade={"persist"}) + * @ORM\OneToOne(targetEntity="Sikofitt\DoughnutWeddingBundle\Entity\User", mappedBy="rsvp", cascade={"persist"}) */ private $user; diff --git a/src/Sikofitt/App/Entity/User.php b/src/Sikofitt/DoughnutWeddingBundle/Entity/User.php similarity index 96% rename from src/Sikofitt/App/Entity/User.php rename to src/Sikofitt/DoughnutWeddingBundle/Entity/User.php index 2de796b..be0233e 100644 --- a/src/Sikofitt/App/Entity/User.php +++ b/src/Sikofitt/DoughnutWeddingBundle/Entity/User.php @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -namespace Sikofitt\App\Entity; +namespace Sikofitt\DoughnutWeddingBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Security\Core\User\UserInterface; @@ -27,7 +27,7 @@ use Symfony\Component\Validator\Constraints as Assert; /** * Class User. * - * @ORM\Entity(repositoryClass="Sikofitt\App\Repository\UserRepository") + * @ORM\Entity(repositoryClass="Sikofitt\DoughnutWeddingBundle\Repository\UserRepository") * @ORM\Table(name="users") */ class User implements UserInterface @@ -104,7 +104,7 @@ class User implements UserInterface /** * @var int - * @ORM\OneToOne(targetEntity="Sikofitt\App\Entity\Rsvp", inversedBy="user", cascade={"persist"}) + * @ORM\OneToOne(targetEntity="Sikofitt\DoughnutWeddingBundle\Entity\Rsvp", inversedBy="user", cascade={"persist"}) */ private $rsvp; /** diff --git a/src/Sikofitt/App/Form/ResetPasswordType.php b/src/Sikofitt/DoughnutWeddingBundle/Form/ResetPasswordType.php similarity index 100% rename from src/Sikofitt/App/Form/ResetPasswordType.php rename to src/Sikofitt/DoughnutWeddingBundle/Form/ResetPasswordType.php diff --git a/src/Sikofitt/App/Form/ResetType.php b/src/Sikofitt/DoughnutWeddingBundle/Form/ResetType.php similarity index 100% rename from src/Sikofitt/App/Form/ResetType.php rename to src/Sikofitt/DoughnutWeddingBundle/Form/ResetType.php diff --git a/src/Sikofitt/App/Form/RsvpType.php b/src/Sikofitt/DoughnutWeddingBundle/Form/RsvpType.php similarity index 100% rename from src/Sikofitt/App/Form/RsvpType.php rename to src/Sikofitt/DoughnutWeddingBundle/Form/RsvpType.php diff --git a/src/Sikofitt/App/Form/UserLoginType.php b/src/Sikofitt/DoughnutWeddingBundle/Form/UserLoginType.php similarity index 100% rename from src/Sikofitt/App/Form/UserLoginType.php rename to src/Sikofitt/DoughnutWeddingBundle/Form/UserLoginType.php diff --git a/src/Sikofitt/App/Form/UserTokenType.php b/src/Sikofitt/DoughnutWeddingBundle/Form/UserTokenType.php similarity index 100% rename from src/Sikofitt/App/Form/UserTokenType.php rename to src/Sikofitt/DoughnutWeddingBundle/Form/UserTokenType.php diff --git a/src/Sikofitt/App/Repository/RsvpRepository.php b/src/Sikofitt/DoughnutWeddingBundle/Repository/RsvpRepository.php similarity index 100% rename from src/Sikofitt/App/Repository/RsvpRepository.php rename to src/Sikofitt/DoughnutWeddingBundle/Repository/RsvpRepository.php diff --git a/src/Sikofitt/App/Repository/UserRepository.php b/src/Sikofitt/DoughnutWeddingBundle/Repository/UserRepository.php similarity index 100% rename from src/Sikofitt/App/Repository/UserRepository.php rename to src/Sikofitt/DoughnutWeddingBundle/Repository/UserRepository.php diff --git a/src/Sikofitt/DoughnutWeddingBundle/Resources/config/services.yml b/src/Sikofitt/DoughnutWeddingBundle/Resources/config/services.yml new file mode 100644 index 0000000..7182e5c --- /dev/null +++ b/src/Sikofitt/DoughnutWeddingBundle/Resources/config/services.yml @@ -0,0 +1,4 @@ +services: +# sikofitt_doughnut_wedding.example: +# class: Sikofitt\DoughnutWeddingBundle\Example +# arguments: ["@service_id", "plain_value", "%parameter%"] diff --git a/src/Sikofitt/DoughnutWeddingBundle/Resources/views/Default/index.html.twig b/src/Sikofitt/DoughnutWeddingBundle/Resources/views/Default/index.html.twig new file mode 100644 index 0000000..980a0d5 --- /dev/null +++ b/src/Sikofitt/DoughnutWeddingBundle/Resources/views/Default/index.html.twig @@ -0,0 +1 @@ +Hello World! diff --git a/src/Sikofitt/Security/MySqlUserProvider.php b/src/Sikofitt/DoughnutWeddingBundle/Security/MySqlUserProvider.php similarity index 100% rename from src/Sikofitt/Security/MySqlUserProvider.php rename to src/Sikofitt/DoughnutWeddingBundle/Security/MySqlUserProvider.php diff --git a/src/Sikofitt/Security/MysqlAuthenticator.php b/src/Sikofitt/DoughnutWeddingBundle/Security/MysqlAuthenticator.php similarity index 100% rename from src/Sikofitt/Security/MysqlAuthenticator.php rename to src/Sikofitt/DoughnutWeddingBundle/Security/MysqlAuthenticator.php diff --git a/src/Sikofitt/Security/ScryptEncoder.php b/src/Sikofitt/DoughnutWeddingBundle/Security/ScryptEncoder.php similarity index 100% rename from src/Sikofitt/Security/ScryptEncoder.php rename to src/Sikofitt/DoughnutWeddingBundle/Security/ScryptEncoder.php diff --git a/src/Sikofitt/Security/TokenGenerator.php b/src/Sikofitt/DoughnutWeddingBundle/Security/TokenGenerator.php similarity index 100% rename from src/Sikofitt/Security/TokenGenerator.php rename to src/Sikofitt/DoughnutWeddingBundle/Security/TokenGenerator.php diff --git a/src/Sikofitt/DoughnutWeddingBundle/SikofittDoughnutWeddingBundle.php b/src/Sikofitt/DoughnutWeddingBundle/SikofittDoughnutWeddingBundle.php new file mode 100644 index 0000000..522a2e9 --- /dev/null +++ b/src/Sikofitt/DoughnutWeddingBundle/SikofittDoughnutWeddingBundle.php @@ -0,0 +1,9 @@ +request('GET', '/'); + + $this->assertContains('Hello World', $client->getResponse()->getContent()); + } +} diff --git a/src/Sikofitt/App/Controller/RsvpControllerProvider.php b/src/Sikofitt/DoughnutWeddingBundle/old/RsvpControllerProvider.php similarity index 100% rename from src/Sikofitt/App/Controller/RsvpControllerProvider.php rename to src/Sikofitt/DoughnutWeddingBundle/old/RsvpControllerProvider.php diff --git a/src/Sikofitt/App/Controller/UserControllerProvider.php b/src/Sikofitt/DoughnutWeddingBundle/old/UserControllerProvider.php similarity index 100% rename from src/Sikofitt/App/Controller/UserControllerProvider.php rename to src/Sikofitt/DoughnutWeddingBundle/old/UserControllerProvider.php diff --git a/tests/AppBundle/Controller/DefaultControllerTest.php b/tests/AppBundle/Controller/DefaultControllerTest.php new file mode 100644 index 0000000..594803c --- /dev/null +++ b/tests/AppBundle/Controller/DefaultControllerTest.php @@ -0,0 +1,18 @@ +request('GET', '/'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertContains('Welcome to Symfony', $crawler->filter('#container h1')->text()); + } +} diff --git a/var/SymfonyRequirements.php b/var/SymfonyRequirements.php new file mode 100644 index 0000000..7e7a99d --- /dev/null +++ b/var/SymfonyRequirements.php @@ -0,0 +1,823 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/* + * Users of PHP 5.2 should be able to run the requirements checks. + * This is why the file and all classes must be compatible with PHP 5.2+ + * (e.g. not using namespaces and closures). + * + * ************** CAUTION ************** + * + * DO NOT EDIT THIS FILE as it will be overridden by Composer as part of + * the installation/update process. The original file resides in the + * SensioDistributionBundle. + * + * ************** CAUTION ************** + */ + +/** + * Represents a single PHP requirement, e.g. an installed extension. + * It can be a mandatory requirement or an optional recommendation. + * There is a special subclass, named PhpIniRequirement, to check a php.ini configuration. + * + * @author Tobias Schultze + */ +class Requirement +{ + private $fulfilled; + private $testMessage; + private $helpText; + private $helpHtml; + private $optional; + + /** + * Constructor that initializes the requirement. + * + * @param bool $fulfilled Whether the requirement is fulfilled + * @param string $testMessage The message for testing the requirement + * @param string $helpHtml The help text formatted in HTML for resolving the problem + * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) + * @param bool $optional Whether this is only an optional recommendation not a mandatory requirement + */ + public function __construct($fulfilled, $testMessage, $helpHtml, $helpText = null, $optional = false) + { + $this->fulfilled = (bool) $fulfilled; + $this->testMessage = (string) $testMessage; + $this->helpHtml = (string) $helpHtml; + $this->helpText = null === $helpText ? strip_tags($this->helpHtml) : (string) $helpText; + $this->optional = (bool) $optional; + } + + /** + * Returns whether the requirement is fulfilled. + * + * @return bool true if fulfilled, otherwise false + */ + public function isFulfilled() + { + return $this->fulfilled; + } + + /** + * Returns the message for testing the requirement. + * + * @return string The test message + */ + public function getTestMessage() + { + return $this->testMessage; + } + + /** + * Returns the help text for resolving the problem. + * + * @return string The help text + */ + public function getHelpText() + { + return $this->helpText; + } + + /** + * Returns the help text formatted in HTML. + * + * @return string The HTML help + */ + public function getHelpHtml() + { + return $this->helpHtml; + } + + /** + * Returns whether this is only an optional recommendation and not a mandatory requirement. + * + * @return bool true if optional, false if mandatory + */ + public function isOptional() + { + return $this->optional; + } +} + +/** + * Represents a PHP requirement in form of a php.ini configuration. + * + * @author Tobias Schultze + */ +class PhpIniRequirement extends Requirement +{ + /** + * Constructor that initializes the requirement. + * + * @param string $cfgName The configuration name used for ini_get() + * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, + * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement + * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. + * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. + * Example: You require a config to be true but PHP later removes this config and defaults it to true internally. + * @param string|null $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) + * @param string|null $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a boolean a default help is derived) + * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) + * @param bool $optional Whether this is only an optional recommendation not a mandatory requirement + */ + public function __construct($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null, $optional = false) + { + $cfgValue = ini_get($cfgName); + + if (is_callable($evaluation)) { + if (null === $testMessage || null === $helpHtml) { + throw new InvalidArgumentException('You must provide the parameters testMessage and helpHtml for a callback evaluation.'); + } + + $fulfilled = call_user_func($evaluation, $cfgValue); + } else { + if (null === $testMessage) { + $testMessage = sprintf('%s %s be %s in php.ini', + $cfgName, + $optional ? 'should' : 'must', + $evaluation ? 'enabled' : 'disabled' + ); + } + + if (null === $helpHtml) { + $helpHtml = sprintf('Set %s to %s in php.ini*.', + $cfgName, + $evaluation ? 'on' : 'off' + ); + } + + $fulfilled = $evaluation == $cfgValue; + } + + parent::__construct($fulfilled || ($approveCfgAbsence && false === $cfgValue), $testMessage, $helpHtml, $helpText, $optional); + } +} + +/** + * A RequirementCollection represents a set of Requirement instances. + * + * @author Tobias Schultze + */ +class RequirementCollection implements IteratorAggregate +{ + /** + * @var Requirement[] + */ + private $requirements = array(); + + /** + * Gets the current RequirementCollection as an Iterator. + * + * @return Traversable A Traversable interface + */ + public function getIterator() + { + return new ArrayIterator($this->requirements); + } + + /** + * Adds a Requirement. + * + * @param Requirement $requirement A Requirement instance + */ + public function add(Requirement $requirement) + { + $this->requirements[] = $requirement; + } + + /** + * Adds a mandatory requirement. + * + * @param bool $fulfilled Whether the requirement is fulfilled + * @param string $testMessage The message for testing the requirement + * @param string $helpHtml The help text formatted in HTML for resolving the problem + * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) + */ + public function addRequirement($fulfilled, $testMessage, $helpHtml, $helpText = null) + { + $this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, false)); + } + + /** + * Adds an optional recommendation. + * + * @param bool $fulfilled Whether the recommendation is fulfilled + * @param string $testMessage The message for testing the recommendation + * @param string $helpHtml The help text formatted in HTML for resolving the problem + * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) + */ + public function addRecommendation($fulfilled, $testMessage, $helpHtml, $helpText = null) + { + $this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, true)); + } + + /** + * Adds a mandatory requirement in form of a php.ini configuration. + * + * @param string $cfgName The configuration name used for ini_get() + * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, + * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement + * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. + * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. + * Example: You require a config to be true but PHP later removes this config and defaults it to true internally. + * @param string $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) + * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a boolean a default help is derived) + * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) + */ + public function addPhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) + { + $this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, false)); + } + + /** + * Adds an optional recommendation in form of a php.ini configuration. + * + * @param string $cfgName The configuration name used for ini_get() + * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, + * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement + * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. + * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. + * Example: You require a config to be true but PHP later removes this config and defaults it to true internally. + * @param string $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) + * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a boolean a default help is derived) + * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) + */ + public function addPhpIniRecommendation($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) + { + $this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, true)); + } + + /** + * Adds a requirement collection to the current set of requirements. + * + * @param RequirementCollection $collection A RequirementCollection instance + */ + public function addCollection(RequirementCollection $collection) + { + $this->requirements = array_merge($this->requirements, $collection->all()); + } + + /** + * Returns both requirements and recommendations. + * + * @return Requirement[] + */ + public function all() + { + return $this->requirements; + } + + /** + * Returns all mandatory requirements. + * + * @return Requirement[] + */ + public function getRequirements() + { + $array = array(); + foreach ($this->requirements as $req) { + if (!$req->isOptional()) { + $array[] = $req; + } + } + + return $array; + } + + /** + * Returns the mandatory requirements that were not met. + * + * @return Requirement[] + */ + public function getFailedRequirements() + { + $array = array(); + foreach ($this->requirements as $req) { + if (!$req->isFulfilled() && !$req->isOptional()) { + $array[] = $req; + } + } + + return $array; + } + + /** + * Returns all optional recommendations. + * + * @return Requirement[] + */ + public function getRecommendations() + { + $array = array(); + foreach ($this->requirements as $req) { + if ($req->isOptional()) { + $array[] = $req; + } + } + + return $array; + } + + /** + * Returns the recommendations that were not met. + * + * @return Requirement[] + */ + public function getFailedRecommendations() + { + $array = array(); + foreach ($this->requirements as $req) { + if (!$req->isFulfilled() && $req->isOptional()) { + $array[] = $req; + } + } + + return $array; + } + + /** + * Returns whether a php.ini configuration is not correct. + * + * @return bool php.ini configuration problem? + */ + public function hasPhpIniConfigIssue() + { + foreach ($this->requirements as $req) { + if (!$req->isFulfilled() && $req instanceof PhpIniRequirement) { + return true; + } + } + + return false; + } + + /** + * Returns the PHP configuration file (php.ini) path. + * + * @return string|false php.ini file path + */ + public function getPhpIniConfigPath() + { + return get_cfg_var('cfg_file_path'); + } +} + +/** + * This class specifies all requirements and optional recommendations that + * are necessary to run the Symfony Standard Edition. + * + * @author Tobias Schultze + * @author Fabien Potencier + */ +class SymfonyRequirements extends RequirementCollection +{ + const LEGACY_REQUIRED_PHP_VERSION = '5.3.3'; + const REQUIRED_PHP_VERSION = '5.5.9'; + + /** + * Constructor that initializes the requirements. + */ + public function __construct() + { + /* mandatory requirements follow */ + + $installedPhpVersion = phpversion(); + $requiredPhpVersion = $this->getPhpRequiredVersion(); + + $this->addRecommendation( + $requiredPhpVersion, + 'Vendors should be installed in order to check all requirements.', + 'Run the composer install command.', + 'Run the "composer install" command.' + ); + + if (false !== $requiredPhpVersion) { + $this->addRequirement( + version_compare($installedPhpVersion, $requiredPhpVersion, '>='), + sprintf('PHP version must be at least %s (%s installed)', $requiredPhpVersion, $installedPhpVersion), + sprintf('You are running PHP version "%s", but Symfony needs at least PHP "%s" to run. + Before using Symfony, upgrade your PHP installation, preferably to the latest version.', + $installedPhpVersion, $requiredPhpVersion), + sprintf('Install PHP %s or newer (installed version is %s)', $requiredPhpVersion, $installedPhpVersion) + ); + } + + $this->addRequirement( + version_compare($installedPhpVersion, '5.3.16', '!='), + 'PHP version must not be 5.3.16 as Symfony won\'t work properly with it', + 'Install PHP 5.3.17 or newer (or downgrade to an earlier PHP version)' + ); + + $this->addRequirement( + is_dir(__DIR__.'/../vendor/composer'), + 'Vendor libraries must be installed', + 'Vendor libraries are missing. Install composer following instructions from http://getcomposer.org/. '. + 'Then run "php composer.phar install" to install them.' + ); + + $cacheDir = is_dir(__DIR__.'/../var/cache') ? __DIR__.'/../var/cache' : __DIR__.'/cache'; + + $this->addRequirement( + is_writable($cacheDir), + 'app/cache/ or var/cache/ directory must be writable', + 'Change the permissions of either "app/cache/" or "var/cache/" directory so that the web server can write into it.' + ); + + $logsDir = is_dir(__DIR__.'/../var/logs') ? __DIR__.'/../var/logs' : __DIR__.'/logs'; + + $this->addRequirement( + is_writable($logsDir), + 'app/logs/ or var/logs/ directory must be writable', + 'Change the permissions of either "app/logs/" or "var/logs/" directory so that the web server can write into it.' + ); + + if (version_compare($installedPhpVersion, '7.0.0', '<')) { + $this->addPhpIniRequirement( + 'date.timezone', true, false, + 'date.timezone setting must be set', + 'Set the "date.timezone" setting in php.ini* (like Europe/Paris).' + ); + } + + if (false !== $requiredPhpVersion && version_compare($installedPhpVersion, $requiredPhpVersion, '>=')) { + $timezones = array(); + foreach (DateTimeZone::listAbbreviations() as $abbreviations) { + foreach ($abbreviations as $abbreviation) { + $timezones[$abbreviation['timezone_id']] = true; + } + } + + $this->addRequirement( + isset($timezones[@date_default_timezone_get()]), + sprintf('Configured default timezone "%s" must be supported by your installation of PHP', @date_default_timezone_get()), + 'Your default timezone is not supported by PHP. Check for typos in your php.ini file and have a look at the list of deprecated timezones at http://php.net/manual/en/timezones.others.php.' + ); + } + + $this->addRequirement( + function_exists('iconv'), + 'iconv() must be available', + 'Install and enable the iconv extension.' + ); + + $this->addRequirement( + function_exists('json_encode'), + 'json_encode() must be available', + 'Install and enable the JSON extension.' + ); + + $this->addRequirement( + function_exists('session_start'), + 'session_start() must be available', + 'Install and enable the session extension.' + ); + + $this->addRequirement( + function_exists('ctype_alpha'), + 'ctype_alpha() must be available', + 'Install and enable the ctype extension.' + ); + + $this->addRequirement( + function_exists('token_get_all'), + 'token_get_all() must be available', + 'Install and enable the Tokenizer extension.' + ); + + $this->addRequirement( + function_exists('simplexml_import_dom'), + 'simplexml_import_dom() must be available', + 'Install and enable the SimpleXML extension.' + ); + + if (function_exists('apc_store') && ini_get('apc.enabled')) { + if (version_compare($installedPhpVersion, '5.4.0', '>=')) { + $this->addRequirement( + version_compare(phpversion('apc'), '3.1.13', '>='), + 'APC version must be at least 3.1.13 when using PHP 5.4', + 'Upgrade your APC extension (3.1.13+).' + ); + } else { + $this->addRequirement( + version_compare(phpversion('apc'), '3.0.17', '>='), + 'APC version must be at least 3.0.17', + 'Upgrade your APC extension (3.0.17+).' + ); + } + } + + $this->addPhpIniRequirement('detect_unicode', false); + + if (extension_loaded('suhosin')) { + $this->addPhpIniRequirement( + 'suhosin.executor.include.whitelist', + create_function('$cfgValue', 'return false !== stripos($cfgValue, "phar");'), + false, + 'suhosin.executor.include.whitelist must be configured correctly in php.ini', + 'Add "phar" to suhosin.executor.include.whitelist in php.ini*.' + ); + } + + if (extension_loaded('xdebug')) { + $this->addPhpIniRequirement( + 'xdebug.show_exception_trace', false, true + ); + + $this->addPhpIniRequirement( + 'xdebug.scream', false, true + ); + + $this->addPhpIniRecommendation( + 'xdebug.max_nesting_level', + create_function('$cfgValue', 'return $cfgValue > 100;'), + true, + 'xdebug.max_nesting_level should be above 100 in php.ini', + 'Set "xdebug.max_nesting_level" to e.g. "250" in php.ini* to stop Xdebug\'s infinite recursion protection erroneously throwing a fatal error in your project.' + ); + } + + $pcreVersion = defined('PCRE_VERSION') ? (float) PCRE_VERSION : null; + + $this->addRequirement( + null !== $pcreVersion, + 'PCRE extension must be available', + 'Install the PCRE extension (version 8.0+).' + ); + + if (extension_loaded('mbstring')) { + $this->addPhpIniRequirement( + 'mbstring.func_overload', + create_function('$cfgValue', 'return (int) $cfgValue === 0;'), + true, + 'string functions should not be overloaded', + 'Set "mbstring.func_overload" to 0 in php.ini* to disable function overloading by the mbstring extension.' + ); + } + + /* optional recommendations follow */ + + if (file_exists(__DIR__.'/../vendor/composer')) { + require_once __DIR__.'/../vendor/autoload.php'; + + try { + $r = new ReflectionClass('Sensio\Bundle\DistributionBundle\SensioDistributionBundle'); + + $contents = file_get_contents(dirname($r->getFileName()).'/Resources/skeleton/app/SymfonyRequirements.php'); + } catch (ReflectionException $e) { + $contents = ''; + } + $this->addRecommendation( + file_get_contents(__FILE__) === $contents, + 'Requirements file should be up-to-date', + 'Your requirements file is outdated. Run composer install and re-check your configuration.' + ); + } + + $this->addRecommendation( + version_compare($installedPhpVersion, '5.3.4', '>='), + 'You should use at least PHP 5.3.4 due to PHP bug #52083 in earlier versions', + 'Your project might malfunction randomly due to PHP bug #52083 ("Notice: Trying to get property of non-object"). Install PHP 5.3.4 or newer.' + ); + + $this->addRecommendation( + version_compare($installedPhpVersion, '5.3.8', '>='), + 'When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156', + 'Install PHP 5.3.8 or newer if your project uses annotations.' + ); + + $this->addRecommendation( + version_compare($installedPhpVersion, '5.4.0', '!='), + 'You should not use PHP 5.4.0 due to the PHP bug #61453', + 'Your project might not work properly due to the PHP bug #61453 ("Cannot dump definitions which have method calls"). Install PHP 5.4.1 or newer.' + ); + + $this->addRecommendation( + version_compare($installedPhpVersion, '5.4.11', '>='), + 'When using the logout handler from the Symfony Security Component, you should have at least PHP 5.4.11 due to PHP bug #63379 (as a workaround, you can also set invalidate_session to false in the security logout handler configuration)', + 'Install PHP 5.4.11 or newer if your project uses the logout handler from the Symfony Security Component.' + ); + + $this->addRecommendation( + (version_compare($installedPhpVersion, '5.3.18', '>=') && version_compare($installedPhpVersion, '5.4.0', '<')) + || + version_compare($installedPhpVersion, '5.4.8', '>='), + 'You should use PHP 5.3.18+ or PHP 5.4.8+ to always get nice error messages for fatal errors in the development environment due to PHP bug #61767/#60909', + 'Install PHP 5.3.18+ or PHP 5.4.8+ if you want nice error messages for all fatal errors in the development environment.' + ); + + if (null !== $pcreVersion) { + $this->addRecommendation( + $pcreVersion >= 8.0, + sprintf('PCRE extension should be at least version 8.0 (%s installed)', $pcreVersion), + 'PCRE 8.0+ is preconfigured in PHP since 5.3.2 but you are using an outdated version of it. Symfony probably works anyway but it is recommended to upgrade your PCRE extension.' + ); + } + + $this->addRecommendation( + class_exists('DomDocument'), + 'PHP-DOM and PHP-XML modules should be installed', + 'Install and enable the PHP-DOM and the PHP-XML modules.' + ); + + $this->addRecommendation( + function_exists('mb_strlen'), + 'mb_strlen() should be available', + 'Install and enable the mbstring extension.' + ); + + $this->addRecommendation( + function_exists('iconv'), + 'iconv() should be available', + 'Install and enable the iconv extension.' + ); + + $this->addRecommendation( + function_exists('utf8_decode'), + 'utf8_decode() should be available', + 'Install and enable the XML extension.' + ); + + $this->addRecommendation( + function_exists('filter_var'), + 'filter_var() should be available', + 'Install and enable the filter extension.' + ); + + if (!defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->addRecommendation( + function_exists('posix_isatty'), + 'posix_isatty() should be available', + 'Install and enable the php_posix extension (used to colorize the CLI output).' + ); + } + + $this->addRecommendation( + extension_loaded('intl'), + 'intl extension should be available', + 'Install and enable the intl extension (used for validators).' + ); + + if (extension_loaded('intl')) { + // in some WAMP server installations, new Collator() returns null + $this->addRecommendation( + null !== new Collator('fr_FR'), + 'intl extension should be correctly configured', + 'The intl extension does not behave properly. This problem is typical on PHP 5.3.X x64 WIN builds.' + ); + + // check for compatible ICU versions (only done when you have the intl extension) + if (defined('INTL_ICU_VERSION')) { + $version = INTL_ICU_VERSION; + } else { + $reflector = new ReflectionExtension('intl'); + + ob_start(); + $reflector->info(); + $output = strip_tags(ob_get_clean()); + + preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches); + $version = $matches[1]; + } + + $this->addRecommendation( + version_compare($version, '4.0', '>='), + 'intl ICU version should be at least 4+', + 'Upgrade your intl extension with a newer ICU version (4+).' + ); + + if (class_exists('Symfony\Component\Intl\Intl')) { + $this->addRecommendation( + \Symfony\Component\Intl\Intl::getIcuDataVersion() <= \Symfony\Component\Intl\Intl::getIcuVersion(), + sprintf('intl ICU version installed on your system is outdated (%s) and does not match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl::getIcuVersion(), \Symfony\Component\Intl\Intl::getIcuDataVersion()), + 'To get the latest internationalization data upgrade the ICU system package and the intl PHP extension.' + ); + if (\Symfony\Component\Intl\Intl::getIcuDataVersion() <= \Symfony\Component\Intl\Intl::getIcuVersion()) { + $this->addRecommendation( + \Symfony\Component\Intl\Intl::getIcuDataVersion() === \Symfony\Component\Intl\Intl::getIcuVersion(), + sprintf('intl ICU version installed on your system (%s) does not match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl::getIcuVersion(), \Symfony\Component\Intl\Intl::getIcuDataVersion()), + 'To avoid internationalization data inconsistencies upgrade the symfony/intl component.' + ); + } + } + + $this->addPhpIniRecommendation( + 'intl.error_level', + create_function('$cfgValue', 'return (int) $cfgValue === 0;'), + true, + 'intl.error_level should be 0 in php.ini', + 'Set "intl.error_level" to "0" in php.ini* to inhibit the messages when an error occurs in ICU functions.' + ); + } + + $accelerator = + (extension_loaded('eaccelerator') && ini_get('eaccelerator.enable')) + || + (extension_loaded('apc') && ini_get('apc.enabled')) + || + (extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.enable')) + || + (extension_loaded('Zend OPcache') && ini_get('opcache.enable')) + || + (extension_loaded('xcache') && ini_get('xcache.cacher')) + || + (extension_loaded('wincache') && ini_get('wincache.ocenabled')) + ; + + $this->addRecommendation( + $accelerator, + 'a PHP accelerator should be installed', + 'Install and/or enable a PHP accelerator (highly recommended).' + ); + + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + $this->addRecommendation( + $this->getRealpathCacheSize() >= 5 * 1024 * 1024, + 'realpath_cache_size should be at least 5M in php.ini', + 'Setting "realpath_cache_size" to e.g. "5242880" or "5M" in php.ini* may improve performance on Windows significantly in some cases.' + ); + } + + $this->addPhpIniRecommendation('short_open_tag', false); + + $this->addPhpIniRecommendation('magic_quotes_gpc', false, true); + + $this->addPhpIniRecommendation('register_globals', false, true); + + $this->addPhpIniRecommendation('session.auto_start', false); + + $this->addRecommendation( + class_exists('PDO'), + 'PDO should be installed', + 'Install PDO (mandatory for Doctrine).' + ); + + if (class_exists('PDO')) { + $drivers = PDO::getAvailableDrivers(); + $this->addRecommendation( + count($drivers) > 0, + sprintf('PDO should have some drivers installed (currently available: %s)', count($drivers) ? implode(', ', $drivers) : 'none'), + 'Install PDO drivers (mandatory for Doctrine).' + ); + } + } + + /** + * Loads realpath_cache_size from php.ini and converts it to int. + * + * (e.g. 16k is converted to 16384 int) + * + * @return int + */ + protected function getRealpathCacheSize() + { + $size = ini_get('realpath_cache_size'); + $size = trim($size); + $unit = ''; + if (!ctype_digit($size)) { + $unit = strtolower(substr($size, -1, 1)); + $size = (int) substr($size, 0, -1); + } + switch ($unit) { + case 'g': + return $size * 1024 * 1024 * 1024; + case 'm': + return $size * 1024 * 1024; + case 'k': + return $size * 1024; + default: + return (int) $size; + } + } + + /** + * Defines PHP required version from Symfony version. + * + * @return string|false The PHP required version or false if it could not be guessed + */ + protected function getPhpRequiredVersion() + { + if (!file_exists($path = __DIR__.'/../composer.lock')) { + return false; + } + + $composerLock = json_decode(file_get_contents($path), true); + foreach ($composerLock['packages'] as $package) { + $name = $package['name']; + if ('symfony/symfony' !== $name && 'symfony/http-kernel' !== $name) { + continue; + } + + return (int) $package['version'][1] > 2 ? self::REQUIRED_PHP_VERSION : self::LEGACY_REQUIRED_PHP_VERSION; + } + + return false; + } +} diff --git a/web/.htaccess b/web/.htaccess new file mode 100644 index 0000000..4dc7251 --- /dev/null +++ b/web/.htaccess @@ -0,0 +1,68 @@ +# Use the front controller as index file. It serves as a fallback solution when +# every other rewrite/redirect fails (e.g. in an aliased environment without +# mod_rewrite). Additionally, this reduces the matching process for the +# start page (path "/") because otherwise Apache will apply the rewriting rules +# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl). +DirectoryIndex app.php + +# By default, Apache does not evaluate symbolic links if you did not enable this +# feature in your server configuration. Uncomment the following line if you +# install assets as symlinks or if you experience problems related to symlinks +# when compiling LESS/Sass/CoffeScript assets. +# Options FollowSymlinks + +# Disabling MultiViews prevents unwanted negotiation, e.g. "/app" should not resolve +# to the front controller "/app.php" but be rewritten to "/app.php/app". + + Options -MultiViews + + + + RewriteEngine On + + # Determine the RewriteBase automatically and set it as environment variable. + # If you are using Apache aliases to do mass virtual hosting or installed the + # project in a subdirectory, the base path will be prepended to allow proper + # resolution of the app.php file and to redirect to the correct URI. It will + # work in environments without path prefix as well, providing a safe, one-size + # fits all solution. But as you do not need it in this case, you can comment + # the following 2 lines to eliminate the overhead. + RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ + RewriteRule ^(.*) - [E=BASE:%1] + + # Sets the HTTP_AUTHORIZATION header removed by Apache + RewriteCond %{HTTP:Authorization} . + RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + + # Redirect to URI without front controller to prevent duplicate content + # (with and without `/app.php`). Only do this redirect on the initial + # rewrite by Apache and not on subsequent cycles. Otherwise we would get an + # endless redirect loop (request -> rewrite to front controller -> + # redirect -> request -> ...). + # So in case you get a "too many redirects" error or you always get redirected + # to the start page because your Apache does not expose the REDIRECT_STATUS + # environment variable, you have 2 choices: + # - disable this feature by commenting the following 2 lines or + # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the + # following RewriteCond (best solution) + RewriteCond %{ENV:REDIRECT_STATUS} ^$ + RewriteRule ^app\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] + + # If the requested filename exists, simply serve it. + # We only want to let Apache serve files and not directories. + RewriteCond %{REQUEST_FILENAME} -f + RewriteRule ^ - [L] + + # Rewrite all other queries to the front controller. + RewriteRule ^ %{ENV:BASE}/app.php [L] + + + + + # When mod_rewrite is not available, we instruct a temporary redirect of + # the start page to the front controller explicitly so that the website + # and the generated links can still be used. + RedirectMatch 302 ^/$ /app.php/ + # RedirectTemp cannot be used instead + + diff --git a/web/app.php b/web/app.php new file mode 100644 index 0000000..6bd0ea0 --- /dev/null +++ b/web/app.php @@ -0,0 +1,18 @@ +loadClassCache(); +//$kernel = new AppCache($kernel); + +// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter +//Request::enableHttpMethodParameterOverride(); +$request = Request::createFromGlobals(); +$response = $kernel->handle($request); +$response->send(); +$kernel->terminate($request, $response); diff --git a/web/app_dev.php b/web/app_dev.php new file mode 100644 index 0000000..e76fcac --- /dev/null +++ b/web/app_dev.php @@ -0,0 +1,30 @@ +loadClassCache(); +$request = Request::createFromGlobals(); +$response = $kernel->handle($request); +$response->send(); +$kernel->terminate($request, $response); diff --git a/web/apple-touch-icon.png b/web/apple-touch-icon.png new file mode 100644 index 0000000..6e6b6ce Binary files /dev/null and b/web/apple-touch-icon.png differ diff --git a/web/config.php b/web/config.php new file mode 100644 index 0000000..4d4d131 --- /dev/null +++ b/web/config.php @@ -0,0 +1,423 @@ +getFailedRequirements(); +$minorProblems = $symfonyRequirements->getFailedRecommendations(); +$hasMajorProblems = (bool) count($majorProblems); +$hasMinorProblems = (bool) count($minorProblems); + +?> + + + + + + Symfony Configuration Checker + + + +
+
+ + + +
+ +
+
+
+

Configuration Checker

+

+ This script analyzes your system to check whether is + ready to run Symfony applications. +

+ + +

Major problems

+

Major problems have been detected and must be fixed before continuing:

+
    + +
  1. getTestMessage() ?> +

    getHelpHtml() ?>

    +
  2. + +
+ + + +

Recommendations

+

+ Additionally, toTo enhance your Symfony experience, + it’s recommended that you fix the following: +

+
    + +
  1. getTestMessage() ?> +

    getHelpHtml() ?>

    +
  2. + +
+ + + hasPhpIniConfigIssue()): ?> +

* + getPhpIniConfigPath()): ?> + Changes to the php.ini file must be done in "getPhpIniConfigPath() ?>". + + To change settings, create a "php.ini". + +

+ + + +

All checks passed successfully. Your system is ready to run Symfony applications.

+ + + +
+
+
+
Symfony Standard Edition
+ +
+ + diff --git a/web/favicon.ico b/web/favicon.ico new file mode 100644 index 0000000..479f7f5 Binary files /dev/null and b/web/favicon.ico differ diff --git a/web/robots.txt b/web/robots.txt new file mode 100644 index 0000000..4665fca --- /dev/null +++ b/web/robots.txt @@ -0,0 +1,5 @@ +# www.robotstxt.org/ +# www.google.com/support/webmasters/bin/answer.py?hl=en&answer=156449 + +User-agent: * +Disallow: