Skip to content

Upgrading symfony/routing 3 to 4

Breakingv3.4.47 → v4.4.44Breaking2Deprecated5New6Changed1Fixed10Other1

BreakingUpgrade verdict

1 breaking change.

  • Routes with non-ASCII characters in their paths must now explicitly enable the utf8 option.
  • The old service-based route loader is being retired; use the newer container loader instead.
  • The old object route loader is being retired; use the newer object loader instead.
  • The old PHP dumper classes are deprecated in favor of the new compiled dumpers.
Top 4 of 6 that need code or config changes

PHP requirement changed in v4.4.11: ^5.5.9|>=7.0.8 → >=7.1.3.

Adds symfony/polyfill-php80 ^1.16.

Breaking1
Drops support for UTF-8 route patterns without using the utf8 option.
utf8
Deprecated5
Deprecates ServiceRouterLoader in favor of ContainerLoader.
ServiceRouterLoaderContainerLoader
Deprecates ObjectRouteLoader in favor of ObjectLoader.
ObjectRouteLoaderObjectLoader
Deprecates PhpGeneratorDumper and PhpMatcherDumper.
PhpGeneratorDumperPhpMatcherDumper
Deprecates the generator_base_class, generator_cache_class, matcher_base_class and matcher_cache_class router options.
generator_base_classgenerator_cache_classmatcher_base_classmatcher_cache_class
Marks Serializable methods on Route and CompiledRoute as @internal and @final, directing users to __serialize and __unserialize.
RouteCompiledRoute__serialize__unserialize

Generated by DepDelta from published PHP source. Not mixed with prose notes.

  • changed: constructor CompiledRoute($staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = …, array $hostTokens = …, array $hostVariables = …, array $variables = …) → constructor CompiledRoute(string $staticPrefix, string $regex, array $tokens, array $pathVariables, string $hostRegex = …, array $hostTokens = …, array $hostVariables = …, array $variables = …)
  • changed: constructor RequestContext($baseUrl = …, $method = …, $host = …, $scheme = …, $httpPort = …, $httpsPort = …, $path = …, $queryString = …) → constructor RequestContext(string $baseUrl = …, string $method = …, string $host = …, string $scheme = …, int $httpPort = …, int $httpsPort = …, string $path = …, string $queryString = …)
  • changed: constructor Route($path, array $defaults = …, array $requirements = …, array $options = …, $host = …, $schemes = …, $methods = …, $condition = …) → constructor Route(string $path, array $defaults = …, array $requirements = …, array $options = …, ?string $host = …, $schemes = …, $methods = …, ?string $condition = …)
  • changed: constructor Router(LoaderInterface $loader, $resource, array $options = …, RequestContext $context = …, LoggerInterface $logger = …) → constructor Router(LoaderInterface $loader, $resource, array $options = …, RequestContext $context = …, LoggerInterface $logger = …, string $defaultLocale = …)
  • added: method CompiledRoute.__serialize(): array
  • added: method CompiledRoute.__unserialize(array $data): void
  • added: method Route.__serialize(): array
  • added: method Route.__unserialize(array $data): void
  • added: method RouteCollection.addNamePrefix(string $prefix)
  • added: protected property Router.defaultLocale
  • added: method Route.getLocalizedPaths(): array
  • added: method Route.setLocalizedPaths(array $localizedPaths)
  • changed: constructor RoutingResolverPass($resolverServiceId = …, $loaderTag = …) → constructor RoutingResolverPass(string $resolverServiceId = …, string $loaderTag = …)
  • changed: constructor MethodNotAllowedException(array $allowedMethods, $message = …, $code = …, \Exception $previous = …) → constructor MethodNotAllowedException(array $allowedMethods, ?string $message = …, int $code = …, \Throwable $previous = …)
  • changed: interface ExceptionInterface → interface ExceptionInterface extends \Throwable
  • changed: constructor UrlGenerator(RouteCollection $routes, RequestContext $context, LoggerInterface $logger = …) → constructor UrlGenerator(RouteCollection $routes, RequestContext $context, LoggerInterface $logger = …, string $defaultLocale = …)
  • added: class CompiledUrlGenerator extends UrlGenerator
  • added: constructor CompiledUrlGenerator(array $compiledRoutes, RequestContext $context, LoggerInterface $logger = …, string $defaultLocale = …)
  • added: method CompiledUrlGenerator.generate($name, $parameters = …, $referenceType = …)
  • added: class CompiledUrlGeneratorDumper extends GeneratorDumper
  • added: method CompiledUrlGeneratorDumper.dump(array $options = …)
  • added: method CompiledUrlGeneratorDumper.getCompiledRoutes(): array
  • removed: method ObjectRouteLoader.load($resource, $type = …)
  • changed: abstract class ObjectRouteLoader extends Loader → abstract class ObjectRouteLoader extends ObjectLoader
  • added: abstract class ObjectLoader extends Loader
  • added: class ContainerLoader extends ObjectLoader
  • added: constructor ContainerLoader(ContainerInterface $container)
  • added: method ContainerLoader.supports($resource, $type = …)
  • added: method ObjectLoader.load($resource, $type = …)
  • added: protected method ContainerLoader.getObject(string $id)
  • added: protected method ObjectLoader.getObject(string $id)
  • added: protected method ObjectRouteLoader.getObject(string $id)
  • removed: method CollectionConfigurator.add($name, $path)
  • changed: constructor CollectionConfigurator(RouteCollection $parent, $name, self $parentConfigurator = …) → constructor CollectionConfigurator(RouteCollection $parent, string $name, self $parentConfigurator = …, array $parentPrefixes = …)
  • changed: constructor RouteConfigurator(RouteCollection $collection, Route $route, $name = …, CollectionConfigurator $parentConfigurator = …) → constructor RouteConfigurator(RouteCollection $collection, $route, string $name = …, CollectionConfigurator $parentConfigurator = …, array $prefixes = …)
  • changed: constructor RoutingConfigurator(RouteCollection $collection, PhpFileLoader $loader, $path, $file) → constructor RoutingConfigurator(RouteCollection $collection, PhpFileLoader $loader, string $path, string $file)
  • changed: method CollectionConfigurator.collection($name = …) → method CollectionConfigurator.collection(string $name = …): self
  • changed: method CollectionConfigurator.prefix($prefix) → method CollectionConfigurator.prefix($prefix): self
  • changed: method ImportConfigurator.prefix($prefix) → method ImportConfigurator.prefix($prefix, bool $trailingSlashOnRoot = …): self
  • changed: method RoutingConfigurator.collection($name = …) → method RoutingConfigurator.collection(string $name = …): CollectionConfigurator
  • changed: method RoutingConfigurator.import($resource, $type = …, $ignoreErrors = …) → method RoutingConfigurator.import($resource, string $type = …, bool $ignoreErrors = …, $exclude = …): ImportConfigurator
  • added: method CollectionConfigurator.__sleep()
  • added: method CollectionConfigurator.__wakeup()
  • added: method ImportConfigurator.__sleep()
  • added: method ImportConfigurator.__wakeup()
  • added: method ImportConfigurator.namePrefix(string $namePrefix): self
  • changed: method AddTrait.__invoke($name, $path) → method AddTrait.__invoke(string $name, $path): RouteConfigurator
  • changed: method AddTrait.add($name, $path) → method AddTrait.add(string $name, $path): RouteConfigurator
  • changed: method RouteTrait.condition($condition) → method RouteTrait.condition(string $condition): self
  • changed: method RouteTrait.controller($controller) → method RouteTrait.controller($controller): self
  • changed: method RouteTrait.defaults(array $defaults) → method RouteTrait.defaults(array $defaults): self
  • changed: method RouteTrait.host($pattern) → method RouteTrait.host(string $pattern): self
  • changed: method RouteTrait.methods(array $methods) → method RouteTrait.methods(array $methods): self
  • changed: method RouteTrait.options(array $options) → method RouteTrait.options(array $options): self
  • changed: method RouteTrait.requirements(array $requirements) → method RouteTrait.requirements(array $requirements): self
  • changed: method RouteTrait.schemes(array $schemes) → method RouteTrait.schemes(array $schemes): self
  • added: method RouteTrait.format(string $format): self
  • added: method RouteTrait.locale(string $locale): self
  • added: method RouteTrait.utf8(bool $utf8 = …): self
  • removed: protected method RedirectableUrlMatcher.handleRouteRequirements($pathinfo, $name, Route $route)
  • changed: protected method UrlMatcher.createRequest($pathinfo) → protected method UrlMatcher.createRequest(string $pathinfo): ?Request
  • added: class CompiledUrlMatcher extends UrlMatcher
  • added: constructor CompiledUrlMatcher(array $compiledRoutes, RequestContext $context)
  • added: protected property UrlMatcher.allowSchemes
  • removed: class DumperCollection implements \IteratorAggregate
  • removed: class DumperRoute
  • removed: constructor DumperRoute($name, Route $route)
  • removed: method DumperCollection.add($child)
  • removed: method DumperCollection.all()
  • removed: method DumperCollection.getAttribute($name, $default = …)
  • removed: method DumperCollection.getIterator()
  • removed: method DumperCollection.getRoot()
  • removed: method DumperCollection.hasAttribute($name)
  • removed: method DumperCollection.setAll(array $children)
  • removed: method DumperCollection.setAttribute($name, $value)
  • removed: method DumperCollection.setAttributes($attributes)
  • removed: method DumperRoute.getName()
  • removed: method DumperRoute.getRoute()
  • removed: method PhpMatcherDumper.addExpressionLanguageProvider(ExpressionFunctionProviderInterface $provider)
  • removed: method StaticPrefixCollection.getItems()
  • removed: method StaticPrefixCollection.optimizeGroups()
  • removed: protected method DumperCollection.getParent()
  • removed: protected method DumperCollection.setParent(self $parent)
  • changed: class PhpMatcherDumper extends MatcherDumper → class PhpMatcherDumper extends CompiledUrlMatcherDumper
  • changed: constructor StaticPrefixCollection($prefix = …) → constructor StaticPrefixCollection(string $prefix = …)
  • changed: method StaticPrefixCollection.addRoute($prefix, $route) → method StaticPrefixCollection.addRoute(string $prefix, $route)
  • changed: method StaticPrefixCollection.getPrefix() → method StaticPrefixCollection.getPrefix(): string
  • added: class CompiledUrlMatcherDumper extends MatcherDumper
  • added: method CompiledUrlMatcherDumper.addExpressionLanguageProvider(ExpressionFunctionProviderInterface $provider)
  • added: method CompiledUrlMatcherDumper.dump(array $options = …)
  • added: method CompiledUrlMatcherDumper.getCompiledRoutes(bool $forDump = …): array
  • added: method CompiledUrlMatcherTrait.match($pathinfo): array
  • added: method StaticPrefixCollection.getRoutes(): array
  • added: method StaticPrefixCollection.populateCollection(RouteCollection $routes): RouteCollection
  • added: static method CompiledUrlMatcherDumper.export($value): string
  • added: static method StaticPrefixCollection.handleError(int $type, string $msg)
  • added: trait CompiledUrlMatcherTrait