diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index 96c652705a..0cee61b0cf 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -1,6 +1,40 @@ UPGRADE FROM 3.x to 4.0 ======================= +Symfony Framework +----------------- + +The first step to upgrade a Symfony 3.x application to 4.x is to update the +file and directory structure of your application: + +| Symfony 3.x | Symfony 4.x +| ----------------------------------- | -------------------------------- +| `app/config/` | `config/` +| `app/config/*.yml` | `config/*.yaml` and `config/packages/*.yaml` +| `app/config/parameters.yml.dist` | `config/services.yaml` and `.env.dist` +| `app/config/parameters.yml` | `config/services.yaml` and `.env` +| `app/Resources//views/` | `templates/bundles//` +| `app/Resources/` | `src/Resources/` +| `app/Resources/assets/` | `assets/` +| `app/Resources/translations/` | `translations/` +| `app/Resources/views/` | `templates/` +| `src/AppBundle/` | `src/` +| `var/logs/` | `var/log/` +| `web/` | `public/` +| `web/app.php` | `public/index.php` +| `web/app_dev.php` | `public/index.php` + +Then, upgrade the contents of your console script and your front controller: + +* `bin/console`: https://github.com/symfony/recipes/blob/master/symfony/console/3.3/bin/console +* `public/index.php`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/3.3/public/index.php + +Lastly, read the following article to add Symfony Flex to your application and +upgrade the configuration files: https://symfony.com/doc/current/setup/flex.html + +If you use Symfony components instead of the whole framework, you can find below +the upgrading instructions for each individual bundle and component. + ClassLoader ----------- diff --git a/src/Symfony/Bridge/Monolog/composer.json b/src/Symfony/Bridge/Monolog/composer.json index 9fcb974602..1deb3ca9d3 100644 --- a/src/Symfony/Bridge/Monolog/composer.json +++ b/src/Symfony/Bridge/Monolog/composer.json @@ -32,7 +32,8 @@ "suggest": { "symfony/http-kernel": "For using the debugging handlers together with the response life cycle of the HTTP kernel.", "symfony/console": "For the possibility to show log messages in console commands depending on verbosity settings. You need version ~2.3 of the console for it.", - "symfony/event-dispatcher": "Needed when using log messages in console commands." + "symfony/event-dispatcher": "Needed when using log messages in console commands.", + "symfony/var-dumper": "For using the debugging handlers like the console handler or the log server handler." }, "autoload": { "psr-4": { "Symfony\\Bridge\\Monolog\\": "" }, diff --git a/src/Symfony/Bundle/WebServerBundle/Command/ServerLogCommand.php b/src/Symfony/Bundle/WebServerBundle/Command/ServerLogCommand.php index 2a92d62eee..8b38748c3e 100644 --- a/src/Symfony/Bundle/WebServerBundle/Command/ServerLogCommand.php +++ b/src/Symfony/Bundle/WebServerBundle/Command/ServerLogCommand.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\WebServerBundle\Command; +use Monolog\Formatter\FormatterInterface; use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter; use Symfony\Bridge\Monolog\Handler\ConsoleHandler; use Symfony\Component\Console\Command\Command; @@ -37,6 +38,11 @@ class ServerLogCommand extends Command return false; } + // based on a symfony/symfony package, it crashes due a missing FormatterInterface from monolog/monolog + if (!class_exists(FormatterInterface::class)) { + return false; + } + return parent::isEnabled(); } diff --git a/src/Symfony/Bundle/WebServerBundle/composer.json b/src/Symfony/Bundle/WebServerBundle/composer.json index 659b4adafc..f51be62350 100644 --- a/src/Symfony/Bundle/WebServerBundle/composer.json +++ b/src/Symfony/Bundle/WebServerBundle/composer.json @@ -29,6 +29,10 @@ "/Tests/" ] }, + "suggest": { + "symfony/monolog-bridge": "For using the log server.", + "symfony/expression-language": "For using the filter option of the log server." + }, "minimum-stability": "dev", "extra": { "branch-alias": { diff --git a/src/Symfony/Component/Console/Event/ConsoleErrorEvent.php b/src/Symfony/Component/Console/Event/ConsoleErrorEvent.php index 49edb723d2..a212a3c287 100644 --- a/src/Symfony/Component/Console/Event/ConsoleErrorEvent.php +++ b/src/Symfony/Component/Console/Event/ConsoleErrorEvent.php @@ -78,6 +78,6 @@ final class ConsoleErrorEvent extends ConsoleEvent */ public function getExitCode() { - return null !== $this->exitCode ? $this->exitCode : ($this->error->getCode() ?: 1); + return null !== $this->exitCode ? $this->exitCode : (is_int($this->error->getCode()) ? $this->error->getCode() : 1); } } diff --git a/src/Symfony/Component/Debug/Tests/phpt/fatal_with_nested_handlers.phpt b/src/Symfony/Component/Debug/Tests/phpt/fatal_with_nested_handlers.phpt index 2a9bcf9b0a..bd7b644dc3 100644 --- a/src/Symfony/Component/Debug/Tests/phpt/fatal_with_nested_handlers.phpt +++ b/src/Symfony/Component/Debug/Tests/phpt/fatal_with_nested_handlers.phpt @@ -33,7 +33,7 @@ array(1) { [0]=> string(37) "Error and exception handlers do match" } -object(Symfony\Component\Debug\Exception\FatalErrorException)#4 (8) { +object(Symfony\Component\Debug\Exception\FatalErrorException)#%d (%d) { ["message":protected]=> string(199) "Error: Class Symfony\Component\Debug\Broken contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Serializable::serialize, Serializable::unserialize)" %a diff --git a/src/Symfony/Component/Translation/MessageSelector.php b/src/Symfony/Component/Translation/MessageSelector.php index c6134191bc..31304cd0d8 100644 --- a/src/Symfony/Component/Translation/MessageSelector.php +++ b/src/Symfony/Component/Translation/MessageSelector.php @@ -49,10 +49,16 @@ class MessageSelector */ public function choose($message, $number, $locale) { - preg_match_all('/(?:\|\||[^\|])++/', $message, $parts); + $parts = array(); + if (preg_match('/^\|++$/', $message)) { + $parts = explode('|', $message); + } elseif (preg_match_all('/(?:\|\||[^\|])++/', $message, $matches)) { + $parts = $matches[0]; + } + $explicitRules = array(); $standardRules = array(); - foreach ($parts[0] as $part) { + foreach ($parts as $part) { $part = trim(str_replace('||', '|', $part)); if (preg_match('/^(?P'.Interval::getIntervalRegexp().')\s*(?P.*?)$/xs', $part, $matches)) { @@ -76,7 +82,7 @@ class MessageSelector if (!isset($standardRules[$position])) { // when there's exactly one rule given, and that rule is a standard // rule, use this rule - if (1 === count($parts[0]) && isset($standardRules[0])) { + if (1 === count($parts) && isset($standardRules[0])) { return $standardRules[0]; } diff --git a/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php b/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php index a9b92c5cee..42b7e0a3fa 100644 --- a/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php +++ b/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php @@ -128,6 +128,10 @@ class MessageSelectorTest extends TestCase array("This is a text with a\nnew-line in it. Selector = 1.", "{0}This is a text with a\nnew-line in it. Selector = 0.|{1}This is a text with a\nnew-line in it. Selector = 1.|[1,Inf]This is a text with a\nnew-line in it. Selector > 1.", 1), // esacape pipe array('This is a text with | in it. Selector = 0.', '{0}This is a text with || in it. Selector = 0.|{1}This is a text with || in it. Selector = 1.', 0), + // Empty plural set (2 plural forms) from a .PO file + array('', '|', 1), + // Empty plural set (3 plural forms) from a .PO file + array('', '||', 1), ); } }