diff --git a/.env.dist b/.env.dist new file mode 100644 index 0000000..7d0f3ea --- /dev/null +++ b/.env.dist @@ -0,0 +1,21 @@ +# This file is a "template" of which env vars need to be defined for your application +# Copy this file to .env file for development, create environment variables when deploying to production +# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration + +###> symfony/framework-bundle ### +APP_ENV=dev +APP_SECRET=xxx +#TRUSTED_PROXIES=127.0.0.1,127.0.0.2 +#TRUSTED_HOSTS=localhost,example.com +###< symfony/framework-bundle ### + +###> doctrine/doctrine-bundle ### +# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url +# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db" +# Configure your db driver and server_version in config/packages/doctrine.yaml +DATABASE_URL=postgres://$PGUSER:$PGPASSWORD@127.0.0.1:5436/test?application_name=point_tools +###< doctrine/doctrine-bundle ### + +###> sentry/sentry-symfony ### +SENTRY_DSN= +###< sentry/sentry-symfony ### \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8e1dd0f..5b2d4da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,7 @@ /.idea/ -/web/bundles/ -/app/bootstrap.php.cache -/app/cache/* -/app/config/parameters.yml -/app/logs/* -!app/cache/.gitkeep -!app/logs/.gitkeep -/app/phpunit.xml -/build/ +/var/cache/* +/var/log/* +!/var/cache/.gitkeep +!/var/log/.gitkeep /vendor/ -/bin/ -/composer.phar +/.env \ No newline at end of file diff --git a/app/.htaccess b/app/.htaccess deleted file mode 100644 index fb1de45..0000000 --- a/app/.htaccess +++ /dev/null @@ -1,7 +0,0 @@ - - Require all denied - - - Order deny,allow - Deny from all - diff --git a/app/AppCache.php b/app/AppCache.php deleted file mode 100644 index ddb51db..0000000 --- a/app/AppCache.php +++ /dev/null @@ -1,9 +0,0 @@ -getEnvironment(), array('dev', 'test'))) { - $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); - $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); - $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle(); - } - - return $bundles; - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml'); - } -} diff --git a/app/SymfonyRequirements.php b/app/SymfonyRequirements.php deleted file mode 100644 index 4a1fcc6..0000000 --- a/app/SymfonyRequirements.php +++ /dev/null @@ -1,810 +0,0 @@ - - * - * 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 = PHP_VERSION; - $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, '>=')) { - $this->addRequirement( - in_array(@date_default_timezone_get(), DateTimeZone::listIdentifiers(), true), - 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('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 ('WIN' === strtoupper(substr(PHP_OS, 0, 3))) { - $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/app/autoload.php b/app/autoload.php deleted file mode 100644 index 70526bb..0000000 --- a/app/autoload.php +++ /dev/null @@ -1,13 +0,0 @@ -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/app/config/config.yml b/app/config/config.yml deleted file mode 100644 index e5ecb61..0000000 --- a/app/config/config.yml +++ /dev/null @@ -1,63 +0,0 @@ -imports: - - { resource: parameters.yml } - - { resource: security.yml } - - { resource: services.yml } - -framework: - #esi: ~ - translator: { fallbacks: ["%locale%"] } - secret: "%secret%" - router: - resource: "%kernel.root_dir%/config/routing.yml" - strict_requirements: ~ - form: ~ - csrf_protection: ~ - validation: { enable_annotations: true } - #serializer: { enable_annotations: true } - default_locale: '%locale%' - trusted_hosts: ~ - session: - # handler_id set to null will use default session handler from php.ini - handler_id: ~ - fragments: ~ - http_method_override: true - assets: ~ - php_errors: - log: true - -sensio_framework_extra: - router: - annotations: false - -sentry: - dsn: '%sentry_dsn%' - -# Twig Configuration -twig: - debug: "%kernel.debug%" - strict_variables: "%kernel.debug%" - form_themes: - - 'bootstrap_3_layout.html.twig' - - 'Form/fields.html.twig' - -# Doctrine Configuration -doctrine: - dbal: - driver: "%database_driver%" - host: "%database_host%" - port: "%database_port%" - dbname: "%database_name%" - user: "%database_user%" - password: "%database_password%" - charset: UTF8 - - orm: - auto_generate_proxy_classes: "%kernel.debug%" - auto_mapping: true - -doctrine_migrations: - dir_name: "%kernel.root_dir%/DoctrineMigrations" - namespace: Application\Migrations - table_name: migration_versions - name: Application Migrations - diff --git a/app/config/config_test.yml b/app/config/config_test.yml deleted file mode 100644 index 0d900f7..0000000 --- a/app/config/config_test.yml +++ /dev/null @@ -1,20 +0,0 @@ -imports: - - { resource: config_dev.yml } - -doctrine: - dbal: - dbname: "%test_database_name%" - port: "%test_database_port%" - user: "%test_database_user%" - password: "%test_database_password%" - -framework: - test: ~ - session: - storage_id: session.storage.mock_file - profiler: - collect: false - -web_profiler: - toolbar: false - intercept_redirects: false diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist deleted file mode 100644 index bff5162..0000000 --- a/app/config/parameters.yml.dist +++ /dev/null @@ -1,18 +0,0 @@ -# This file is a "template" of what your parameters.yml file should look like -parameters: - database_driver: pdo_mysql - database_host: 127.0.0.1 - database_port: ~ - database_name: symfony - database_user: root - database_password: ~ - # You should uncomment this if you want use pdo_sqlite - # database_path: "%kernel.root_dir%/data.db3" - - locale: en - - # A secret key that's used to generate certain security-related tokens - secret: ThisTokenIsNotSoSecretChangeIt - - # Sentry logging - sentry_dsn: ~ \ No newline at end of file diff --git a/app/config/routing.yml b/app/config/routing.yml deleted file mode 100644 index 36812d1..0000000 --- a/app/config/routing.yml +++ /dev/null @@ -1,21 +0,0 @@ -paste_show_public: - path: /{id} - defaults: { _controller: 'Skobkin\Bundle\CopyPasteBundle\Controller\PasteController::showAction', secret: null } - requirements: - id: \d+ - -paste_show_private: - path: /{id}/{secret} - defaults: { _controller: 'Skobkin\Bundle\CopyPasteBundle\Controller\PasteController::showAction' } - requirements: - id: \d+ - secret: \w{16} - -paste_new: - path: / - defaults: { _controller: 'Skobkin\Bundle\CopyPasteBundle\Controller\PasteController::newAction' } - -paste_create: - path: /create - defaults: { _controller: 'Skobkin\Bundle\CopyPasteBundle\Controller\PasteController::createAction' } - methods: POST \ No newline at end of file diff --git a/app/config/routing_dev.yml b/app/config/routing_dev.yml deleted file mode 100644 index 404f6a3..0000000 --- a/app/config/routing_dev.yml +++ /dev/null @@ -1,14 +0,0 @@ -_wdt: - resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml" - prefix: /_wdt - -_profiler: - resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml" - prefix: /_profiler - -_errors: - resource: "@TwigBundle/Resources/config/routing/errors.xml" - prefix: /_error - -_main: - resource: routing.yml diff --git a/app/config/services.yml b/app/config/services.yml deleted file mode 100644 index 718e7c3..0000000 --- a/app/config/services.yml +++ /dev/null @@ -1,30 +0,0 @@ -# Learn more about services, parameters and containers at -# http://symfony.com/doc/current/book/service_container.html -parameters: -# parameter_name: value - -services: - # default configuration for services in *this* file - _defaults: - # automatically injects dependencies in your services - autowire: true - # automatically registers your services as commands, event subscribers, etc. - autoconfigure: true - # this means you cannot fetch services directly from the container via $container->get() - # if you need to do this, you can override this setting on individual services - public: false - - # makes classes in src/AppBundle available to be used as services - # this creates a service per class whose id is the fully-qualified class name - Skobkin\Bundle\CopyPasteBundle\: - resource: '../../src/Skobkin/Bundle/CopyPasteBundle/*' - # you can exclude directories or files - # but if a service is unused, it's removed anyway - exclude: '../../src/Skobkin/Bundle/CopyPasteBundle/{DataFixtures,DependencyInjection,Entity,Repository,Tests}' - - # controllers are imported separately to make sure they're public - # and have a tag that allows actions to type-hint services - Skobkin\Bundle\CopyPasteBundle\Controller\: - resource: '../../src/Skobkin/Bundle/CopyPasteBundle/Controller' - public: true - tags: ['controller.service_arguments'] diff --git a/app/console b/app/console deleted file mode 100644 index f14e052..0000000 --- a/app/console +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env php -getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev', true); -$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption('--no-debug', true) && $env !== 'prod'; -if ($debug) { - Debug::enable(); -} -$kernel = new AppKernel($env, $debug); -$application = new Application($kernel); -$application->run($input); \ No newline at end of file diff --git a/app/phpunit.xml.dist b/app/phpunit.xml.dist deleted file mode 100644 index 2b41503..0000000 --- a/app/phpunit.xml.dist +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - ../src/*/*Bundle/Tests - ../src/*/Bundle/*Bundle/Tests - ../src/*Bundle/Tests - - - - - - - - ../src - - ../src/*Bundle/Resources - ../src/*Bundle/Tests - ../src/*/*Bundle/Resources - ../src/*/*Bundle/Tests - ../src/*/Bundle/*Bundle/Resources - ../src/*/Bundle/*Bundle/Tests - - - - diff --git a/bin/console b/bin/console new file mode 100755 index 0000000..ec2be25 --- /dev/null +++ b/bin/console @@ -0,0 +1,28 @@ +#!/usr/bin/env php +getParameterOption(['--env', '-e'], null, true)) { + putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); +} +if ($input->hasParameterOption('--no-debug', true)) { + putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); +} +require dirname(__DIR__).'/config/bootstrap.php'; +if ($_SERVER['APP_DEBUG']) { + umask(0000); + if (class_exists(Debug::class)) { + Debug::enable(); + } +} +$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); +$application = new Application($kernel); +$application->run($input); \ No newline at end of file diff --git a/bin/doctrine b/bin/doctrine new file mode 120000 index 0000000..0f72e36 --- /dev/null +++ b/bin/doctrine @@ -0,0 +1 @@ +../vendor/doctrine/orm/bin/doctrine \ No newline at end of file diff --git a/bin/doctrine-dbal b/bin/doctrine-dbal new file mode 120000 index 0000000..110e93c --- /dev/null +++ b/bin/doctrine-dbal @@ -0,0 +1 @@ +../vendor/doctrine/dbal/bin/doctrine-dbal \ No newline at end of file diff --git a/bin/doctrine-migrations b/bin/doctrine-migrations new file mode 120000 index 0000000..7184da7 --- /dev/null +++ b/bin/doctrine-migrations @@ -0,0 +1 @@ +../vendor/doctrine/migrations/bin/doctrine-migrations \ No newline at end of file diff --git a/bin/sentry b/bin/sentry new file mode 120000 index 0000000..775ae14 --- /dev/null +++ b/bin/sentry @@ -0,0 +1 @@ +../vendor/sentry/sentry/bin/sentry \ No newline at end of file diff --git a/composer.json b/composer.json index 32c82fe..edcdc35 100644 --- a/composer.json +++ b/composer.json @@ -4,8 +4,14 @@ "type": "project", "description": "Online code sharing app", "autoload": { - "psr-4": { "": "src/" }, - "classmap": [ "app/AppKernel.php", "app/AppCache.php" ] + "psr-4": { + "App\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "App\\Tests\\": "tests/" + } }, "minimum-stability": "stable", "require": { @@ -18,42 +24,37 @@ "incenteev/composer-parameter-handler": "^2.0", "sensio/framework-extra-bundle": "^5", "sentry/sentry-symfony": "^2.2", + "symfony/flex": "^1.1", "symfony/monolog-bundle": "^3.1", - "symfony/symfony": "^3.4", "theodordiaconu/geshi": "dev-master", "theodordiaconu/geshi-bundle": "dev-master" },"require-dev": { - "symfony/web-server-bundle": "^3.4" + "symfony/web-server-bundle": "^4.2" + }, + "conflict": { + "symfony/symfony": "*" }, "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" - ], + "auto-scripts": { + "cache:clear": "symfony-cmd", + "assets:install %PUBLIC_DIR%": "symfony-cmd" + }, "post-install-cmd": [ - "@symfony-scripts" + "@auto-scripts" ], "post-update-cmd": [ - "@symfony-scripts" + "@auto-scripts" ] }, "config": { - "bin-dir": "bin", + "preferred-install": { + "*": "dist" + }, "sort-packages": true }, "extra": { - "symfony-app-dir": "app", - "symfony-web-dir": "web", - "symfony-assets-install": "relative", - "incenteev-parameters": { - "file": "app/config/parameters.yml" - }, - "branch-alias": { - "dev-master": "3.1-dev" + "symfony": { + "allow-contrib": false } } } diff --git a/composer.lock b/composer.lock index 7e5c867..ff7583a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0218e8260fd98189a3dccdd39583ddff", + "content-hash": "d2f44b3978879aaf95f741728ffc9e5f", "packages": [ { "name": "doctrine/annotations", @@ -1710,51 +1710,6 @@ ], "time": "2018-09-27T13:45:01+00:00" }, - { - "name": "paragonie/random_compat", - "version": "v9.99.99", - "source": { - "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", - "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", - "shasum": "" - }, - "require": { - "php": "^7" - }, - "require-dev": { - "phpunit/phpunit": "4.*|5.*", - "vimeo/psalm": "^1" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", - "keywords": [ - "csprng", - "polyfill", - "pseudorandom", - "random" - ], - "time": "2018-07-02T15:55:56+00:00" - }, { "name": "psr/cache", "version": "1.0.1", @@ -2198,6 +2153,121 @@ ], "time": "2019-01-05T13:33:24+00:00" }, + { + "name": "symfony/contracts", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/contracts.git", + "reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/contracts/zipball/1aa7ab2429c3d594dd70689604b5cf7421254cdf", + "reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "require-dev": { + "psr/cache": "^1.0", + "psr/container": "^1.0" + }, + "suggest": { + "psr/cache": "When using the Cache contracts", + "psr/container": "When using the Service contracts", + "symfony/cache-contracts-implementation": "", + "symfony/service-contracts-implementation": "", + "symfony/translation-contracts-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\": "" + }, + "exclude-from-classmap": [ + "**/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A set of abstractions extracted out of the Symfony components", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2018-12-05T08:06:11+00:00" + }, + { + "name": "symfony/flex", + "version": "v1.1.8", + "source": { + "type": "git", + "url": "https://github.com/symfony/flex.git", + "reference": "955774ecf07b10230bb5b44e150ba078b45f68fa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/flex/zipball/955774ecf07b10230bb5b44e150ba078b45f68fa", + "reference": "955774ecf07b10230bb5b44e150ba078b45f68fa", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0", + "php": "^7.0" + }, + "require-dev": { + "composer/composer": "^1.0.2", + "symfony/phpunit-bridge": "^3.2.8" + }, + "type": "composer-plugin", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + }, + "class": "Symfony\\Flex\\Flex" + }, + "autoload": { + "psr-4": { + "Symfony\\Flex\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien.potencier@gmail.com" + } + ], + "description": "Composer plugin for Symfony", + "time": "2018-11-15T06:11:38+00:00" + }, { "name": "symfony/monolog-bundle", "version": "v3.3.1", @@ -2261,62 +2331,6 @@ ], "time": "2018-11-04T09:58:13+00:00" }, - { - "name": "symfony/polyfill-apcu", - "version": "v1.10.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-apcu.git", - "reference": "19e1b73bf255265ad0b568f81766ae2a3266d8d2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-apcu/zipball/19e1b73bf255265ad0b568f81766ae2a3266d8d2", - "reference": "19e1b73bf255265ad0b568f81766ae2a3266d8d2", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.9-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Apcu\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting apcu_* functions to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "apcu", - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2018-08-06T14:22:27+00:00" - }, { "name": "symfony/polyfill-ctype", "version": "v1.10.0", @@ -2493,22 +2507,21 @@ "time": "2018-09-21T13:07:52+00:00" }, { - "name": "symfony/polyfill-php56", + "name": "symfony/polyfill-php72", "version": "v1.10.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php56.git", - "reference": "ff208829fe1aa48ab9af356992bb7199fed551af" + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "9050816e2ca34a8e916c3a0ae8b9c2fccf68b631" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/ff208829fe1aa48ab9af356992bb7199fed551af", - "reference": "ff208829fe1aa48ab9af356992bb7199fed551af", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/9050816e2ca34a8e916c3a0ae8b9c2fccf68b631", + "reference": "9050816e2ca34a8e916c3a0ae8b9c2fccf68b631", "shasum": "" }, "require": { - "php": ">=5.3.3", - "symfony/polyfill-util": "~1.0" + "php": ">=5.3.3" }, "type": "library", "extra": { @@ -2518,7 +2531,7 @@ }, "autoload": { "psr-4": { - "Symfony\\Polyfill\\Php56\\": "" + "Symfony\\Polyfill\\Php72\\": "" }, "files": [ "bootstrap.php" @@ -2538,7 +2551,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions", + "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", @@ -2546,167 +2559,59 @@ "portable", "shim" ], - "time": "2018-09-21T06:26:08+00:00" - }, - { - "name": "symfony/polyfill-php70", - "version": "v1.10.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "6b88000cdd431cd2e940caa2cb569201f3f84224" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/6b88000cdd431cd2e940caa2cb569201f3f84224", - "reference": "6b88000cdd431cd2e940caa2cb569201f3f84224", - "shasum": "" - }, - "require": { - "paragonie/random_compat": "~1.0|~2.0|~9.99", - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.9-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php70\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2018-09-21T06:26:08+00:00" - }, - { - "name": "symfony/polyfill-util", - "version": "v1.10.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-util.git", - "reference": "3b58903eae668d348a7126f999b0da0f2f93611c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/3b58903eae668d348a7126f999b0da0f2f93611c", - "reference": "3b58903eae668d348a7126f999b0da0f2f93611c", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.9-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Util\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony utilities for portability of PHP codes", - "homepage": "https://symfony.com", - "keywords": [ - "compat", - "compatibility", - "polyfill", - "shim" - ], - "time": "2018-09-30T16:36:12+00:00" + "time": "2018-09-21T13:07:52+00:00" }, { "name": "symfony/symfony", - "version": "v3.4.21", + "version": "v4.2.2", "source": { "type": "git", "url": "https://github.com/symfony/symfony.git", - "reference": "c7a57e0bcc3c57ae697f072b3e862487b6fd0030" + "reference": "4b3e32332fd3559a644a262be53228422e5393d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/symfony/zipball/c7a57e0bcc3c57ae697f072b3e862487b6fd0030", - "reference": "c7a57e0bcc3c57ae697f072b3e862487b6fd0030", + "url": "https://api.github.com/repos/symfony/symfony/zipball/4b3e32332fd3559a644a262be53228422e5393d3", + "reference": "4b3e32332fd3559a644a262be53228422e5393d3", "shasum": "" }, "require": { - "doctrine/common": "~2.4", + "doctrine/collections": "~1.0", + "doctrine/event-manager": "~1.0", + "doctrine/persistence": "~1.0", "ext-xml": "*", "fig/link-util": "^1.0", - "php": "^5.5.9|>=7.0.8", + "php": "^7.1.3", "psr/cache": "~1.0", "psr/container": "^1.0", "psr/link": "^1.0", "psr/log": "~1.0", "psr/simple-cache": "^1.0", - "symfony/polyfill-apcu": "~1.1", + "symfony/contracts": "^1.0.2", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-icu": "~1.0", "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php56": "~1.0", - "symfony/polyfill-php70": "~1.6", + "symfony/polyfill-php72": "~1.5", "twig/twig": "^1.35|^2.4.4" }, "conflict": { "phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.2", "phpdocumentor/type-resolver": "<0.3.0", - "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0" + "phpunit/phpunit": "<5.4.3" }, "provide": { "psr/cache-implementation": "1.0", "psr/container-implementation": "1.0", "psr/log-implementation": "1.0", - "psr/simple-cache-implementation": "1.0" + "psr/simple-cache-implementation": "1.0", + "symfony/cache-contracts": "1.0", + "symfony/service-contracts": "1.0", + "symfony/translation-contracts": "1.0" }, "replace": { "symfony/asset": "self.version", "symfony/browser-kit": "self.version", "symfony/cache": "self.version", - "symfony/class-loader": "self.version", "symfony/config": "self.version", "symfony/console": "self.version", "symfony/css-selector": "self.version", @@ -2728,6 +2633,7 @@ "symfony/intl": "self.version", "symfony/ldap": "self.version", "symfony/lock": "self.version", + "symfony/messenger": "self.version", "symfony/monolog-bridge": "self.version", "symfony/options-resolver": "self.version", "symfony/process": "self.version", @@ -2749,6 +2655,7 @@ "symfony/twig-bundle": "self.version", "symfony/validator": "self.version", "symfony/var-dumper": "self.version", + "symfony/var-exporter": "self.version", "symfony/web-link": "self.version", "symfony/web-profiler-bundle": "self.version", "symfony/web-server-bundle": "self.version", @@ -2763,18 +2670,19 @@ "doctrine/dbal": "~2.4", "doctrine/doctrine-bundle": "~1.4", "doctrine/orm": "~2.4,>=2.4.5", + "doctrine/reflection": "~1.0", "egulias/email-validator": "~1.2,>=1.2.8|~2.0", "monolog/monolog": "~1.11", "ocramius/proxy-manager": "~0.4|~1.0|~2.0", "phpdocumentor/reflection-docblock": "^3.0|^4.0", - "predis/predis": "~1.0", + "predis/predis": "~1.1", "symfony/phpunit-bridge": "~3.4|~4.0", "symfony/security-acl": "~2.8|~3.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -2812,7 +2720,7 @@ "keywords": [ "framework" ], - "time": "2019-01-06T15:54:26+00:00" + "time": "2019-01-06T16:19:41+00:00" }, { "name": "theodordiaconu/geshi", @@ -3069,7 +2977,53 @@ "time": "2018-04-25T15:33:34+00:00" } ], - "packages-dev": [], + "packages-dev": [ + { + "name": "paragonie/random_compat", + "version": "v9.99.99", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "shasum": "" + }, + "require": { + "php": "^7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "time": "2018-07-02T15:55:56+00:00" + } + ], "aliases": [], "minimum-stability": "stable", "stability-flags": { diff --git a/config/bootstrap.php b/config/bootstrap.php new file mode 100644 index 0000000..c52f821 --- /dev/null +++ b/config/bootstrap.php @@ -0,0 +1,17 @@ +=1.2) +if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) { + $_SERVER += $env; + $_ENV += $env; +} elseif (!class_exists(Dotenv::class)) { + throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); +} else { + // load all the .env files + (new Dotenv())->loadEnv(dirname(__DIR__).'/.env'); +} +$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; +$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV']; +$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0'; diff --git a/config/bundles.php b/config/bundles.php new file mode 100644 index 0000000..97c1560 --- /dev/null +++ b/config/bundles.php @@ -0,0 +1,17 @@ + ['all' => true], + Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], + Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], + Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], + Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], + Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], + Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['all' => true], + Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], + DT\Bundle\GeshiBundle\DTGeshiBundle::class => ['all' => true], + Sentry\SentryBundle\SentryBundle::class => ['all' => true], + Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true], + Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], + Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true, 'test' => true], +]; \ No newline at end of file diff --git a/app/config/config_dev.yml b/config/packages/dev/monolog.yaml similarity index 78% rename from app/config/config_dev.yml rename to config/packages/dev/monolog.yaml index b30a818..479f837 100644 --- a/app/config/config_dev.yml +++ b/config/packages/dev/monolog.yaml @@ -1,16 +1,3 @@ -imports: - - { resource: config.yml } - -framework: - router: - resource: "%kernel.root_dir%/config/routing_dev.yml" - strict_requirements: true - profiler: { only_exceptions: false } - -web_profiler: - toolbar: true - intercept_redirects: false - monolog: handlers: main: diff --git a/config/packages/dev/routing.yaml b/config/packages/dev/routing.yaml new file mode 100644 index 0000000..4116679 --- /dev/null +++ b/config/packages/dev/routing.yaml @@ -0,0 +1,3 @@ +framework: + router: + strict_requirements: true diff --git a/config/packages/dev/web_profiler.yaml b/config/packages/dev/web_profiler.yaml new file mode 100644 index 0000000..1f1cb2b --- /dev/null +++ b/config/packages/dev/web_profiler.yaml @@ -0,0 +1,3 @@ +web_profiler: + toolbar: true + intercept_redirects: false diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml new file mode 100644 index 0000000..5d5dd1d --- /dev/null +++ b/config/packages/doctrine.yaml @@ -0,0 +1,14 @@ +parameters: + env(DATABASE_URL): '' + +doctrine: + dbal: + default_connection: default + connections: + default: + driver: 'mysqli' + url: '%env(resolve:DATABASE_URL)%' + charset: UTF8 + + orm: + auto_generate_proxy_classes: "%kernel.debug%" diff --git a/config/packages/doctrine_migrations.yaml b/config/packages/doctrine_migrations.yaml new file mode 100644 index 0000000..b5aa645 --- /dev/null +++ b/config/packages/doctrine_migrations.yaml @@ -0,0 +1,3 @@ +doctrine_migrations: + dir_name: '%kernel.project_dir%/src/Migrations' + namespace: Migrations diff --git a/config/packages/form.yaml b/config/packages/form.yaml new file mode 100644 index 0000000..b0eeb43 --- /dev/null +++ b/config/packages/form.yaml @@ -0,0 +1,3 @@ +framework: + form: ~ + csrf_protection: ~ diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml new file mode 100644 index 0000000..a52f4a2 --- /dev/null +++ b/config/packages/framework.yaml @@ -0,0 +1,12 @@ +framework: + #esi: ~ + secret: '%env(APP_SECRET)%' + trusted_hosts: ~ + session: + # handler_id set to null will use default session handler from php.ini + handler_id: ~ + fragments: ~ + http_method_override: true + assets: ~ + php_errors: + log: true diff --git a/app/config/config_prod.yml b/config/packages/prod/monolog.yaml similarity index 59% rename from app/config/config_prod.yml rename to config/packages/prod/monolog.yaml index 342837a..25f2c67 100644 --- a/app/config/config_prod.yml +++ b/config/packages/prod/monolog.yaml @@ -1,16 +1,3 @@ -imports: - - { resource: config.yml } - -#framework: -# validation: -# cache: apc - -#doctrine: -# orm: -# metadata_cache_driver: apc -# result_cache_driver: apc -# query_cache_driver: apc - monolog: handlers: main: diff --git a/config/packages/prod/sentry.yaml b/config/packages/prod/sentry.yaml new file mode 100644 index 0000000..b957d81 --- /dev/null +++ b/config/packages/prod/sentry.yaml @@ -0,0 +1,2 @@ +sentry: + dsn: '%sentry_dsn%' diff --git a/config/packages/routing.yaml b/config/packages/routing.yaml new file mode 100644 index 0000000..368bc7f --- /dev/null +++ b/config/packages/routing.yaml @@ -0,0 +1,3 @@ +framework: + router: + strict_requirements: ~ diff --git a/app/config/security.yml b/config/packages/security.yaml similarity index 100% rename from app/config/security.yml rename to config/packages/security.yaml diff --git a/config/packages/sensio_framework_extra.yaml b/config/packages/sensio_framework_extra.yaml new file mode 100644 index 0000000..20e5cf3 --- /dev/null +++ b/config/packages/sensio_framework_extra.yaml @@ -0,0 +1,3 @@ +sensio_framework_extra: + router: + annotations: false \ No newline at end of file diff --git a/config/packages/sentry.yaml b/config/packages/sentry.yaml new file mode 100644 index 0000000..97bee87 --- /dev/null +++ b/config/packages/sentry.yaml @@ -0,0 +1,3 @@ +sentry: + options: + curl_method: async diff --git a/config/packages/serializer.yaml b/config/packages/serializer.yaml new file mode 100644 index 0000000..1795b43 --- /dev/null +++ b/config/packages/serializer.yaml @@ -0,0 +1,3 @@ +framework: + serializer: + enable_annotations: true diff --git a/config/packages/test/doctrine.yaml b/config/packages/test/doctrine.yaml new file mode 100644 index 0000000..4b2ec5d --- /dev/null +++ b/config/packages/test/doctrine.yaml @@ -0,0 +1,6 @@ +doctrine: + dbal: + dbname: "%test_database_name%" + port: "%test_database_port%" + user: "%test_database_user%" + password: "%test_database_password%" diff --git a/config/packages/test/framework.yaml b/config/packages/test/framework.yaml new file mode 100644 index 0000000..344d275 --- /dev/null +++ b/config/packages/test/framework.yaml @@ -0,0 +1,6 @@ +framework: + test: ~ + session: + storage_id: session.storage.mock_file + profiler: + collect: false diff --git a/config/packages/test/web_profiler.yaml b/config/packages/test/web_profiler.yaml new file mode 100644 index 0000000..85319b4 --- /dev/null +++ b/config/packages/test/web_profiler.yaml @@ -0,0 +1,3 @@ +web_profiler: + toolbar: false + intercept_redirects: false diff --git a/config/packages/translation.yaml b/config/packages/translation.yaml new file mode 100644 index 0000000..1edfbe2 --- /dev/null +++ b/config/packages/translation.yaml @@ -0,0 +1,7 @@ +framework: + default_locale: '%locale%' + translator: + paths: + - '%kernel.project_dir%/translations' + fallbacks: + - '%locale%' diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml new file mode 100644 index 0000000..81fef93 --- /dev/null +++ b/config/packages/twig.yaml @@ -0,0 +1,6 @@ +twig: + debug: "%kernel.debug%" + strict_variables: "%kernel.debug%" + form_themes: + - 'bootstrap_3_layout.html.twig' + - 'Form/fields.html.twig' diff --git a/config/packages/validation.yaml b/config/packages/validation.yaml new file mode 100644 index 0000000..61807db --- /dev/null +++ b/config/packages/validation.yaml @@ -0,0 +1,3 @@ +framework: + validation: + enable_annotations: true diff --git a/config/routes.yaml b/config/routes.yaml new file mode 100644 index 0000000..49e4ce1 --- /dev/null +++ b/config/routes.yaml @@ -0,0 +1,21 @@ +paste_show_public: + path: /{id} + defaults: { _controller: 'App\Controller\PasteController::showAction', secret: null } + requirements: + id: \d+ + +paste_show_private: + path: /{id}/{secret} + defaults: { _controller: 'App\Controller\PasteController::showAction' } + requirements: + id: \d+ + secret: \w{16} + +paste_new: + path: / + defaults: { _controller: 'App\Controller\PasteController::newAction' } + +paste_create: + path: /create + defaults: { _controller: 'App\Controller\PasteController::createAction' } + methods: POST \ No newline at end of file diff --git a/config/routes/dev/twig.yaml b/config/routes/dev/twig.yaml new file mode 100644 index 0000000..f4ee839 --- /dev/null +++ b/config/routes/dev/twig.yaml @@ -0,0 +1,3 @@ +_errors: + resource: '@TwigBundle/Resources/config/routing/errors.xml' + prefix: /_error diff --git a/config/routes/dev/web_profiles.yaml b/config/routes/dev/web_profiles.yaml new file mode 100644 index 0000000..c82beff --- /dev/null +++ b/config/routes/dev/web_profiles.yaml @@ -0,0 +1,7 @@ +web_profiler_wdt: + resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml' + prefix: /_wdt + +web_profiler_profiler: + resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml' + prefix: /_profiler diff --git a/config/services.yaml b/config/services.yaml new file mode 100644 index 0000000..fe6be92 --- /dev/null +++ b/config/services.yaml @@ -0,0 +1,24 @@ +# Learn more about services, parameters and containers at +# http://symfony.com/doc/current/book/service_container.html +parameters: + locale: 'ru' + container.dumper.inline_class_loader: true + +services: + # default configuration for services in *this* file + _defaults: + # automatically injects dependencies in your services + autowire: true + # automatically registers your services as commands, event subscribers, etc. + autoconfigure: true + # this means you cannot fetch services directly from the container via $container->get() + # if you need to do this, you can override this setting on individual services + public: false + + App\: + resource: '../src/*' + exclude: '../src/{DataFixtures,Entity,Migrations,Tests,Kernel.php}' + + App\Controller\: + resource: '../src/Controller' + tags: ['controller.service_arguments'] diff --git a/src/Skobkin/Bundle/CopyPasteBundle/Resources/public/css/base.css b/public/css/base.css similarity index 100% rename from src/Skobkin/Bundle/CopyPasteBundle/Resources/public/css/base.css rename to public/css/base.css diff --git a/web/favicon.ico b/public/favicon.ico similarity index 100% rename from web/favicon.ico rename to public/favicon.ico diff --git a/src/Skobkin/Bundle/CopyPasteBundle/Resources/public/images/favicon.ico b/public/images/favicon.ico similarity index 100% rename from src/Skobkin/Bundle/CopyPasteBundle/Resources/public/images/favicon.ico rename to public/images/favicon.ico diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..c52f821 --- /dev/null +++ b/public/index.php @@ -0,0 +1,17 @@ +=1.2) +if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) { + $_SERVER += $env; + $_ENV += $env; +} elseif (!class_exists(Dotenv::class)) { + throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); +} else { + // load all the .env files + (new Dotenv())->loadEnv(dirname(__DIR__).'/.env'); +} +$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; +$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV']; +$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0'; diff --git a/src/Skobkin/Bundle/CopyPasteBundle/Resources/public/js/copypaste.js b/public/js/copypaste.js similarity index 100% rename from src/Skobkin/Bundle/CopyPasteBundle/Resources/public/js/copypaste.js rename to public/js/copypaste.js diff --git a/web/robots.txt b/public/robots.txt similarity index 100% rename from web/robots.txt rename to public/robots.txt diff --git a/src/Skobkin/Bundle/CopyPasteBundle/Command/DropExpiredCopypastesCommand.php b/src/Command/DropExpiredPasteCommand.php similarity index 56% rename from src/Skobkin/Bundle/CopyPasteBundle/Command/DropExpiredCopypastesCommand.php rename to src/Command/DropExpiredPasteCommand.php index 9570fde..91c5db9 100644 --- a/src/Skobkin/Bundle/CopyPasteBundle/Command/DropExpiredCopypastesCommand.php +++ b/src/Command/DropExpiredPasteCommand.php @@ -1,21 +1,30 @@ em = $em; + } + protected function configure() { $this @@ -27,17 +36,14 @@ class DropExpiredCopypastesCommand extends ContainerAwareCommand protected function execute(InputInterface $input, OutputInterface $output) { $output->write('Deleting expired entities...'); - - /* @var $em EntityManager */ - $em = $this->getContainer()->get('doctrine')->getManager(); // @todo move to repository - $queryBuilder = $em->createQueryBuilder() - ->delete('SkobkinCopyPasteBundle:Copypaste c') + $qb = $this->em->createQueryBuilder() + ->delete(Copypaste::class, 'c') ->where('c.dateExpire < :now') ->andWhere('c.dateExpire IS NOT NULL') ->setParameter('now', new \DateTime()); - $queryBuilder->getQuery()->execute(); + $qb->getQuery()->execute(); $output->writeln('Done.'); } diff --git a/src/Skobkin/Bundle/CopyPasteBundle/Controller/PasteController.php b/src/Controller/PasteController.php similarity index 75% rename from src/Skobkin/Bundle/CopyPasteBundle/Controller/PasteController.php rename to src/Controller/PasteController.php index d94c3c2..6d90231 100644 --- a/src/Skobkin/Bundle/CopyPasteBundle/Controller/PasteController.php +++ b/src/Controller/PasteController.php @@ -1,26 +1,19 @@ createCreateForm($paste); @@ -63,31 +56,7 @@ class PasteController extends Controller throw $this->createAccessDeniedException('Sorry :('); } - /** - * Creates a form to create a Copypaste entity. - * - * @param Copypaste $entity The entity - * - * @return Form The form - */ - private function createCreateForm(Copypaste $entity) - { - $form = $this->createForm(CopypasteType::class, $entity, [ - 'action' => $this->generateUrl('paste_create'), - 'method' => 'POST', - ]); - - $form->add('submit', SubmitType::class, ['label' => 'Create']); - - return $form; - } - - /** - * Displays a form to create a new Copypaste entity. - * - * @return Response - */ - public function newAction() + public function newAction(): Response { $paste = new Copypaste(); $createForm = $this->createCreateForm($paste); @@ -98,16 +67,11 @@ class PasteController extends Controller ]); } - /** - * Finds and displays a Copypaste entity. - * - * @return Response - */ - public function showAction(int $id, ?string $secret, HighlighterInterface $highlighter) + public function showAction(int $id, ?string $secret, HighlighterInterface $highlighter): Response { $em = $this->getDoctrine()->getManager(); - /* @var $paste Copypaste */ + /* @var $paste \App\Entity\Copypaste */ $paste = $em->getRepository(Copypaste::class)->findOneBy([ 'id' =>$id, 'secret' => $secret @@ -130,13 +94,8 @@ class PasteController extends Controller 'form_create' => $editForm->createView(), ]); } - - /** - * Main page - * - * @return Response - */ - public function sidebarAction() + + public function sidebarAction(): Response { $em = $this->getDoctrine()->getManager(); @@ -149,4 +108,16 @@ class PasteController extends Controller return $this->render('sidebar.html.twig', ['pastes' => $pastes]); } + + private function createCreateForm(Copypaste $entity): FormInterface + { + $form = $this->createForm(CopypasteType::class, $entity, [ + 'action' => $this->generateUrl('paste_create'), + 'method' => 'POST', + ]); + + $form->add('submit', SubmitType::class, ['label' => 'Create']); + + return $form; + } } diff --git a/src/Skobkin/Bundle/CopyPasteBundle/DataFixtures/ORM/LoadLanguages.php b/src/DataFixtures/ORM/LoadLanguages.php similarity index 96% rename from src/Skobkin/Bundle/CopyPasteBundle/DataFixtures/ORM/LoadLanguages.php rename to src/DataFixtures/ORM/LoadLanguages.php index 905492e..a23bc3a 100644 --- a/src/Skobkin/Bundle/CopyPasteBundle/DataFixtures/ORM/LoadLanguages.php +++ b/src/DataFixtures/ORM/LoadLanguages.php @@ -1,6 +1,6 @@ datePublished = new \DateTime(); } - /** - * Get id - * - * @return integer - */ - public function getId() + public function getId(): int { return $this->id; } @@ -113,219 +104,108 @@ class Copypaste return (string) $this->id; } - /** - * Set text - * - * @param string $text - * @return Paste - */ - public function setText($text) + public function setText(string $text): self { $this->text = $text; return $this; } - /** - * Get text - * - * @return string - */ - public function getText() + public function getText(): string { return $this->text; } - /** - * Set description - * - * @param string $description - * @return Paste - */ - public function setDescription($description) + public function setDescription(string $description): self { $this->description = $description; return $this; } - /** - * Get code description - * - * @return string - */ - public function getDescription() + public function getDescription(): ?string { return $this->description; } - /** - * Set language - * - * @param integer $language - * @return Paste - */ - public function setLanguage($language) + public function setLanguage(Language $language): self { $this->language = $language; return $this; } - /** - * Get language - * - * @return integer - */ - public function getLanguage() + public function getLanguage(): Language { return $this->language; } - /** - * Set filename - * - * @param string $filename - * @return Paste - */ - public function setFilename($filename) + public function setFilename(string $filename): self { $this->fileName = $filename; return $this; } - /** - * Get filename - * - * @return string - */ - public function getFilename() + public function getFilename(): ?string { return $this->fileName; } - /** - * Set author - * - * @param string $author - * @return Paste - */ - public function setAuthor($author) + public function setAuthor(string $author): self { $this->author = $author; return $this; } - /** - * Get author - * - * @return string - */ - public function getAuthor() + public function getAuthor(): ?string { return $this->author; } - /** - * Set publication date - * - * @param \DateTime $datePublished - * @return Paste - */ - public function setDatePublished($datePublished) - { - $this->datePublished = $datePublished; - - return $this; - } - - /** - * Get publication date - * - * @return \DateTime - */ - public function getDatePublished() + public function getDatePublished(): \DateTime { return $this->datePublished; } - /** - * Set expiration date - * - * @param \DateTime $dateExpire - * @return Paste - */ - public function setDateExpire($dateExpire) + public function setDateExpire(\DateTime $dateExpire): self { $this->dateExpire = $dateExpire; return $this; } - /** - * Get expiration date - * - * @return \DateTime - */ - public function getDateExpire() + public function getDateExpire(): ?\DateTime { return $this->dateExpire; } - /** - * Set ip - * - * @param string $ip - * @return Paste - */ - public function setIp($ip) + public function setIp(string $ip): self { $this->ip = $ip; return $this; } - /** - * Get ip - * - * @return string - */ - public function getIp() + public function getIp(): string { return $this->ip; } - /** - * Set secret - * - * @param string $secret - * @return Paste - */ - public function setSecret($secret) + public function setSecret(?string $secret): self { $this->secret = $secret; return $this; } - /** - * Get secret - * - * @return string - */ - public function getSecret() + public function getSecret(): ?string { return $this->secret; } - - /** - * Check if copypaste is private - * - * @return boolean - */ - public function isPrivate() + + public function isPrivate(): bool { return ($this->secret === null) ? false : true; } diff --git a/src/Skobkin/Bundle/CopyPasteBundle/Entity/Language.php b/src/Entity/Language.php similarity index 97% rename from src/Skobkin/Bundle/CopyPasteBundle/Entity/Language.php rename to src/Entity/Language.php index 75f3cf9..41597a9 100644 --- a/src/Skobkin/Bundle/CopyPasteBundle/Entity/Language.php +++ b/src/Entity/Language.php @@ -1,6 +1,6 @@ add('language', EntityType::class, [ 'label' => 'paste_add_form_language', - 'class' => 'Skobkin\Bundle\CopyPasteBundle\Entity\Language', + 'class' => Language::class, 'query_builder' => function (EntityRepository $repo) { /* @var $qb QueryBuilder */ return $repo->createQueryBuilder('lang') @@ -79,23 +80,10 @@ class CopypasteType extends AbstractType ; } - /** - * @param OptionsResolver $resolver - */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => 'Skobkin\Bundle\CopyPasteBundle\Entity\Copypaste' + 'data_class' => Copypaste::class ]); } - - /** - * @return null|string - */ - public function getBlockPrefix() - { - return 'copypaste'; - } - - } diff --git a/src/Skobkin/Bundle/CopyPasteBundle/Form/FakeCaptchaType.php b/src/Form/FakeCaptchaType.php similarity index 76% rename from src/Skobkin/Bundle/CopyPasteBundle/Form/FakeCaptchaType.php rename to src/Form/FakeCaptchaType.php index 58a4c4b..2e6750a 100644 --- a/src/Skobkin/Bundle/CopyPasteBundle/Form/FakeCaptchaType.php +++ b/src/Form/FakeCaptchaType.php @@ -1,6 +1,6 @@ getProjectDir().'/config/bundles.php'; + foreach ($contents as $class => $envs) { + if ($envs[$this->environment] ?? $envs['all'] ?? false) { + yield new $class(); + } + } + } + protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader) + { + $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php')); + $container->setParameter('container.dumper.inline_class_loader', true); + $confDir = $this->getProjectDir().'/config'; + $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob'); + } + protected function configureRoutes(RouteCollectionBuilder $routes) + { + $confDir = $this->getProjectDir().'/config'; + $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob'); + } +} diff --git a/app/DoctrineMigrations/Version20150302205121.php b/src/Migrations/Version20150302205121.php similarity index 98% rename from app/DoctrineMigrations/Version20150302205121.php rename to src/Migrations/Version20150302205121.php index 637c634..a3d67c0 100644 --- a/app/DoctrineMigrations/Version20150302205121.php +++ b/src/Migrations/Version20150302205121.php @@ -1,6 +1,6 @@ root('skobkin_copy_paste'); - - // 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/Skobkin/Bundle/CopyPasteBundle/DependencyInjection/SkobkinCopyPasteExtension.php b/src/Skobkin/Bundle/CopyPasteBundle/DependencyInjection/SkobkinCopyPasteExtension.php deleted file mode 100644 index 8728e2a..0000000 --- a/src/Skobkin/Bundle/CopyPasteBundle/DependencyInjection/SkobkinCopyPasteExtension.php +++ /dev/null @@ -1,27 +0,0 @@ -processConfiguration($configuration, $configs); - - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - } -} diff --git a/src/Skobkin/Bundle/CopyPasteBundle/SkobkinCopyPasteBundle.php b/src/Skobkin/Bundle/CopyPasteBundle/SkobkinCopyPasteBundle.php deleted file mode 100644 index d5c8cd6..0000000 --- a/src/Skobkin/Bundle/CopyPasteBundle/SkobkinCopyPasteBundle.php +++ /dev/null @@ -1,9 +0,0 @@ - + {% endblock %} {% block javascript %} {{- parent() -}} - + {% endblock %} {%- block header -%} @@ -46,7 +46,7 @@ {%- endblock -%} {%- block sidebar -%} - {{ render(controller('Skobkin\\Bundle\\CopyPasteBundle\\Controller\\PasteController::sidebarAction')) }} + {{ render(controller('App\\Controller\\PasteController::sidebarAction')) }} {%- endblock -%} {% block content %}{% endblock %} diff --git a/app/Resources/views/layout.html.twig b/templates/layout.html.twig similarity index 95% rename from app/Resources/views/layout.html.twig rename to templates/layout.html.twig index 11caa5c..7755374 100644 --- a/app/Resources/views/layout.html.twig +++ b/templates/layout.html.twig @@ -4,7 +4,7 @@ {%- block head -%} {% block title %}CopyPaste{% endblock %} - + {%- block css -%} {%- endblock -%} diff --git a/app/Resources/views/sidebar.html.twig b/templates/sidebar.html.twig similarity index 100% rename from app/Resources/views/sidebar.html.twig rename to templates/sidebar.html.twig diff --git a/app/cache/.gitkeep b/tests/.gitkeep similarity index 100% rename from app/cache/.gitkeep rename to tests/.gitkeep diff --git a/app/Resources/translations/messages.ru.xliff b/translations/messages.ru.xliff similarity index 100% rename from app/Resources/translations/messages.ru.xliff rename to translations/messages.ru.xliff diff --git a/app/logs/.gitkeep b/var/cache/.gitkeep similarity index 100% rename from app/logs/.gitkeep rename to var/cache/.gitkeep diff --git a/var/log/.gitkeep b/var/log/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/web/.htaccess b/web/.htaccess deleted file mode 100644 index 94b3892..0000000 --- a/web/.htaccess +++ /dev/null @@ -1,62 +0,0 @@ -# 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 - -# 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}/$2 [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 deleted file mode 100644 index 433163b..0000000 --- a/web/app.php +++ /dev/null @@ -1,17 +0,0 @@ -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); \ No newline at end of file diff --git a/web/app_dev.php b/web/app_dev.php deleted file mode 100644 index 1d9e45f..0000000 --- a/web/app_dev.php +++ /dev/null @@ -1,26 +0,0 @@ -loadClassCache(); -} -$request = Request::createFromGlobals(); -$response = $kernel->handle($request); -$response->send(); -$kernel->terminate($request, $response); \ No newline at end of file