This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/UPGRADE-3.0.md

116 lines
3.4 KiB
Markdown
Raw Normal View History

2013-01-15 07:06:36 +00:00
UPGRADE FROM 2.x to 3.0
=======================
### ClassLoader
* The `UniversalClassLoader` class has been removed in favor of
`ClassLoader`. 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 of
`DebugClassLoader`. The difference is that the constructor now takes a
loader to wrap.
2013-01-16 22:09:43 +00:00
### HttpKernel
* The `Symfony\Component\HttpKernel\Log\LoggerInterface` has been removed in
favor of `Psr\Log\LoggerInterface`. The only difference is that some method
names are different:
* `emerg()` -> `emergency()`
* `crit()` -> `critical()`
* `err()` -> `error()`
* `warn()` -> `warning()`
2013-01-16 22:09:43 +00:00
The previous method renames also happened to the following classes:
* `Symfony\Bridge\Monolog\Logger`
* `Symfony\Component\HttpKernel\Log\NullLogger`
2013-01-16 22:09:43 +00:00
* 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`
2013-01-15 07:06:36 +00:00
### Routing
* Some route settings have been renamed:
* The `pattern` setting for a route has been deprecated in favor of `path`
* The `_scheme` and `_method` requirements have been moved to the `schemes` and `methods` settings
2013-01-15 07:06:36 +00:00
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+' }
2013-01-15 18:31:20 +00:00
<route id="article_edit" path="/article/{id}" methods="POST PUT" schemes="https">
2013-01-15 07:06:36 +00:00
<requirement key="id">\d+</requirement>
</route>
$route = new Route();
$route->setPath('/article/{id}');
$route->setMethods(array('POST', 'PUT'));
$route->setSchemes('https');
```
### Translator
* The `Translator::setFallbackLocale()` method has been removed in favor of
`Translator::setFallbackLocales()`.
### Twig Bridge
* The `render` tag is deprecated in favor of the `render` 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));
```