4.1 KiB
UPGRADE FROM 2.x to 3.0
ClassLoader
-
The
UniversalClassLoader
class has been removed in favor ofClassLoader
. The only difference is that some method names are different:registerNamespaces()
->addPrefixes()
registerPrefixes()
->addPrefixes()
registerNamespaces()
->addPrefix()
registerPrefixes()
->addPrefix()
getNamespaces()
->getPrefixes()
getNamespaceFallbacks()
->getFallbackDirs()
getPrefixFallbacks()
->getFallbackDirs()
-
The
DebugUniversalClassLoader
class has been removed in favor ofDebugClassLoader
. The difference is that the constructor now takes a loader to wrap.
HttpKernel
-
The
Symfony\Component\HttpKernel\Log\LoggerInterface
has been removed in favor ofPsr\Log\LoggerInterface
. The only difference is that some method names are different:emerg()
->emergency()
crit()
->critical()
err()
->error()
warn()
->warning()
The previous method renames also happened to the following classes:
Symfony\Bridge\Monolog\Logger
Symfony\Component\HttpKernel\Log\NullLogger
-
The
Symfony\Component\HttpKernel\Kernel::init()
method has been removed. -
The following classes have been renamed as they have been moved to the Debug component:
Symfony\Component\HttpKernel\Debug\ErrorHandler
->Symfony\Component\Debug\ErrorHandler
Symfony\Component\HttpKernel\Debug\ExceptionHandler
->Symfony\Component\Debug\ExceptionHandler
Symfony\Component\HttpKernel\Exception\FatalErrorException
->Symfony\Component\Debug\Exception\FatalErrorException
Symfony\Component\HttpKernel\Exception\FlattenException
->Symfony\Component\Debug\Exception\FlattenException
Routing
-
Some route settings have been renamed:
- The
pattern
setting for a route has been deprecated in favor ofpath
- The
_scheme
and_method
requirements have been moved to theschemes
andmethods
settings
Before:
article_edit: pattern: /article/{id} requirements: { '_method': 'POST|PUT', '_scheme': 'https', 'id': '\d+' } <route id="article_edit" pattern="/article/{id}"> <requirement key="_method">POST|PUT</requirement> <requirement key="_scheme">https</requirement> <requirement key="id">\d+</requirement> </route> $route = new Route(); $route->setPattern('/article/{id}'); $route->setRequirement('_method', 'POST|PUT'); $route->setRequirement('_scheme', 'https');
After:
article_edit: path: /article/{id} methods: [POST, PUT] schemes: https requirements: { 'id': '\d+' } <route id="article_edit" path="/article/{id}" methods="POST PUT" schemes="https"> <requirement key="id">\d+</requirement> </route> $route = new Route(); $route->setPath('/article/{id}'); $route->setMethods(array('POST', 'PUT')); $route->setSchemes('https');
- The
Translator
- The
Translator::setFallbackLocale()
method has been removed in favor ofTranslator::setFallbackLocales()
.
Twig Bridge
- The
render
tag is deprecated in favor of therender
function.
Yaml
-
The ability to pass file names to
Yaml::parse()
has been removed.Before:
Yaml::parse($fileName);
After:
Yaml::parse(file_get_contents($fileName));
Validator
-
The constraints
Optional
andRequired
were moved to theSymfony\Component\Validator\Constraints\
namespace. You should adapt the path wherever you used them.Before:
use Symfony\Component\Validator\Constraints as Assert; /** * @Assert\Collection({ * "foo" = @Assert\Collection\Required(), * "bar" = @Assert\Collection\Optional(), * }) */ private $property;
After:
use Symfony\Component\Validator\Constraints as Assert; /** * @Assert\Collection({ * "foo" = @Assert\Required(), * "bar" = @Assert\Optional(), * }) */ private $property;