8000 Doc CompiledUrlMatcherDumper instead of PhpMatcherDumper by nicolas-grekas · Pull Request #10790 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Doc CompiledUrlMatcherDumper instead of PhpMatcherDumper #10790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Doc CompiledUrlMatcherDumper instead of PhpMatcherDumper
  • Loading branch information
nicolas-grekas committed Jan 23, 2019
commit 8e8df56022a6d740e2fdd59e32e73c8b7a0416f0
10 changes: 8 additions & 2 deletions create_framework/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ generate absolute URLs::
highly optimized URL matcher class that can replace the default
``UrlMatcher``::

$dumper = new Routing\Matcher\Dumper\PhpMatcherDumper($routes);
use Symfony\Component\Routing\Matcher\CompiledUrlMatcher;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherDumper;

echo $dumper->dump();
// $compiledRoutes is a plain PHP array that describes
// all routes using a performant data format
// you can and SHOULD cache it, typically by exporting it to a PHP file
$compiledRoutes = (new CompiledUrlMatcherDumper($routes))->getCompiledRoutes();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, if you are concerned about performance, you should not write the code like you do in this example. You need to cache the compiled routes somehow. Otherwise, the time spent compiling routes might still be longer than the time won on matching.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. I added a note about it, good to you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems good


$matcher = new CompiledUrlMatcher($compiledRoutes, $context);
0