From 4a42c695b10233db8605e66e0088d4d6a20954b9 Mon Sep 17 00:00:00 2001
From: mamazu <14860264+mamazu@users.noreply.github.com>
Date: Fri, 21 Mar 2025 11:12:21 +0100
Subject: [PATCH 01/23] Adding command to generate all routes as yaml
---
Command/GenerateRoutes.php | 59 ++++++++++++++++++++++++++++++++++++
Resources/config/routing.xml | 6 ++++
composer.json | 1 +
3 files changed, 66 insertions(+)
create mode 100644 Command/GenerateRoutes.php
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
new file mode 100644
index 0000000..33e5d02
--- /dev/null
+++ b/Command/GenerateRoutes.php
@@ -0,0 +1,59 @@
+projectDirectory = $projectDirectory;
+ $this->router = $router;
+
+ parent::__construct('fos-routing:generate-symfony');
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output): int
+ {
+ $routes = [];
+ foreach ($this->router->getRouteCollection() as $name => $route) {
+ $routeData = $route->__serialize();
+ // Unset things that are probably defaulted by Symfony
+ unset($routeData['options']['compiler_class']);
+ unset($routeData['options']['utf8']);
+ $routeData['controller'] = $routeData['defaults']['_controller'] ?? '';
+ unset($routeData['defaults']['_controller']);
+
+ foreach ($routeData as $key => $value) {
+ if (!$value) {
+ unset($routeData[$key]);
+ }
+ }
+ $routes[$name] = $routeData;
+ }
+
+ ksort($routes);
+
+ $targetPath = $this->projectDirectory . '/fos-routing.yaml';
+ file_put_contents($targetPath, Yaml::dump($routes));
+
+ $io = new SymfonyStyle($input, $output);
+ $io->note('Generated routes to: ' . $targetPath);
+ $io->comment('This is a list of all routes in the project. Please copy and paste the relevant routes to your config.');
+
+ $io->info('If you do not like yaml. You can use the symplify/config-transformer package to change it into php.');
+
+ return Command::SUCCESS;
+ }
+}
diff --git a/Resources/config/routing.xml b/Resources/config/routing.xml
index 7f9a879..69c4690 100644
--- a/Resources/config/routing.xml
+++ b/Resources/config/routing.xml
@@ -53,6 +53,12 @@
+
+
+ %kernel.project_dir%
+
+
+
diff --git a/composer.json b/composer.json
index 9dfb1b9..1f9f74a 100644
--- a/composer.json
+++ b/composer.json
@@ -25,6 +25,7 @@
"php": "^7.2 || ^8.0",
"doctrine/annotations": "^1.0|^2.0",
"doctrine/inflector": "^1.4.1|^2.0",
+ "symfony/console": "^4.4|^5.0|^6.0|^7.0",
"symfony/config": "^4.4|^5.0|^6.0|^7.0",
"symfony/dependency-injection": "^4.4|^5.0|^6.0|^7.0",
"symfony/finder": "^4.4|^5.0|^6.0|^7.0",
From 6fab4da86b8dcc1184c101db92eea9bb0fbee6ab Mon Sep 17 00:00:00 2001
From: mamazu <14860264+mamazu@users.noreply.github.com>
Date: Tue, 10 Jun 2025 09:27:26 +0200
Subject: [PATCH 02/23] Update Command/GenerateRoutes.php
Co-authored-by: Alexander Schranz
---
Command/GenerateRoutes.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
index 33e5d02..040404f 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/GenerateRoutes.php
@@ -34,6 +34,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
unset($routeData['options']['utf8']);
$routeData['controller'] = $routeData['defaults']['_controller'] ?? '';
unset($routeData['defaults']['_controller']);
+ $routeData['format'] = $routeData['defaults']['_format'] ?? '';
+ unset($routeData['defaults']['_controller']);
foreach ($routeData as $key => $value) {
if (!$value) {
From fa2ebf01dae57be2a14f5c94cd506df83aa8ff66 Mon Sep 17 00:00:00 2001
From: mamazu <14860264+mamazu@users.noreply.github.com>
Date: Tue, 10 Jun 2025 09:27:34 +0200
Subject: [PATCH 03/23] Update Command/GenerateRoutes.php
Co-authored-by: Alexander Schranz
---
Command/GenerateRoutes.php | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
index 040404f..5447075 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/GenerateRoutes.php
@@ -36,6 +36,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
unset($routeData['defaults']['_controller']);
$routeData['format'] = $routeData['defaults']['_format'] ?? '';
unset($routeData['defaults']['_controller']);
+ $defaults= $routeData['defaults'] ?? [];
+ $requirements= $routeData['requirements'] ?? [];
+ unset($routeData['defaults']);
+ unset($routeData['requirements']);
+ if ($defaults !== []) {
+ $routeData['defaults'] = $defaults;
+ }
+ if ($requirements !== []) {
+ $routeData['requirements'] = $requirements;
+ }
foreach ($routeData as $key => $value) {
if (!$value) {
From 8cbd825aa8d0920b66e7b9e00942d7b9c4676bb4 Mon Sep 17 00:00:00 2001
From: mamazu <14860264+mamazu@users.noreply.github.com>
Date: Tue, 10 Jun 2025 09:27:46 +0200
Subject: [PATCH 04/23] Update Command/GenerateRoutes.php
Co-authored-by: Alexander Schranz
---
Command/GenerateRoutes.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
index 5447075..1d2470c 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/GenerateRoutes.php
@@ -32,6 +32,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// Unset things that are probably defaulted by Symfony
unset($routeData['options']['compiler_class']);
unset($routeData['options']['utf8']);
+ if (\is_array($routeData['methods'] ?? null) && \count($routeData['methods']) === 1) {
+ $routeData['methods'] = $routeData['methods'][0];
+ }
$routeData['controller'] = $routeData['defaults']['_controller'] ?? '';
unset($routeData['defaults']['_controller']);
$routeData['format'] = $routeData['defaults']['_format'] ?? '';
From ffb63cb6abcb88759821571a1334e0b3cbf6d8ca Mon Sep 17 00:00:00 2001
From: mamazu <14860264+mamazu@users.noreply.github.com>
Date: Tue, 10 Jun 2025 09:27:53 +0200
Subject: [PATCH 05/23] Update Command/GenerateRoutes.php
Co-authored-by: Alexander Schranz
---
Command/GenerateRoutes.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
index 1d2470c..2b36ca8 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/GenerateRoutes.php
@@ -58,7 +58,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$routes[$name] = $routeData;
}
- ksort($routes);
$targetPath = $this->projectDirectory . '/fos-routing.yaml';
file_put_contents($targetPath, Yaml::dump($routes));
From fe049e74ec2a56583d43451cdda813ed2a15b64f Mon Sep 17 00:00:00 2001
From: mamazu <14860264+mamazu@users.noreply.github.com>
Date: Tue, 10 Jun 2025 10:00:27 +0200
Subject: [PATCH 06/23] Using output instead of filewrite
---
Command/GenerateRoutes.php | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
index 2b36ca8..16403e0 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/GenerateRoutes.php
@@ -60,11 +60,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$targetPath = $this->projectDirectory . '/fos-routing.yaml';
- file_put_contents($targetPath, Yaml::dump($routes));
+ echo Yaml::dump($routes);
$io = new SymfonyStyle($input, $output);
- $io->note('Generated routes to: ' . $targetPath);
- $io->comment('This is a list of all routes in the project. Please copy and paste the relevant routes to your config.');
$io->info('If you do not like yaml. You can use the symplify/config-transformer package to change it into php.');
From d77a3ca4f0f63aba0123b56b3525dfc785ebb4ed Mon Sep 17 00:00:00 2001
From: mamazu <14860264+mamazu@users.noreply.github.com>
Date: Tue, 10 Jun 2025 10:01:17 +0200
Subject: [PATCH 07/23] Running cs fixer
---
Command/GenerateRoutes.php | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
index 16403e0..396832d 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/GenerateRoutes.php
@@ -32,22 +32,22 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// Unset things that are probably defaulted by Symfony
unset($routeData['options']['compiler_class']);
unset($routeData['options']['utf8']);
- if (\is_array($routeData['methods'] ?? null) && \count($routeData['methods']) === 1) {
- $routeData['methods'] = $routeData['methods'][0];
+ if (\is_array($routeData['methods'] ?? null) && 1 === \count($routeData['methods'])) {
+ $routeData['methods'] = $routeData['methods'][0];
}
$routeData['controller'] = $routeData['defaults']['_controller'] ?? '';
unset($routeData['defaults']['_controller']);
$routeData['format'] = $routeData['defaults']['_format'] ?? '';
unset($routeData['defaults']['_controller']);
- $defaults= $routeData['defaults'] ?? [];
- $requirements= $routeData['requirements'] ?? [];
+ $defaults = $routeData['defaults'] ?? [];
+ $requirements = $routeData['requirements'] ?? [];
unset($routeData['defaults']);
unset($routeData['requirements']);
- if ($defaults !== []) {
- $routeData['defaults'] = $defaults;
+ if ([] !== $defaults) {
+ $routeData['defaults'] = $defaults;
}
- if ($requirements !== []) {
- $routeData['requirements'] = $requirements;
+ if ([] !== $requirements) {
+ $routeData['requirements'] = $requirements;
}
foreach ($routeData as $key => $value) {
@@ -58,7 +58,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$routes[$name] = $routeData;
}
-
$targetPath = $this->projectDirectory . '/fos-routing.yaml';
echo Yaml::dump($routes);
From 5661017b57a9acef5d9a1882e08739311dad9e3a Mon Sep 17 00:00:00 2001
From: mamazu <14860264+mamazu@users.noreply.github.com>
Date: Tue, 10 Jun 2025 10:01:55 +0200
Subject: [PATCH 08/23] Update Command/GenerateRoutes.php
Co-authored-by: Alexander Schranz
---
Command/GenerateRoutes.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
index 396832d..043d38b 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/GenerateRoutes.php
@@ -59,7 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
$targetPath = $this->projectDirectory . '/fos-routing.yaml';
- echo Yaml::dump($routes);
+ $output->writleln(Yaml::dump($routes));
$io = new SymfonyStyle($input, $output);
From 19446e86a31c89c27b6f0329a758d828f41c6988 Mon Sep 17 00:00:00 2001
From: mamazu <14860264+mamazu@users.noreply.github.com>
Date: Tue, 10 Jun 2025 10:21:35 +0200
Subject: [PATCH 09/23] Adding filters
---
Command/GenerateRoutes.php | 40 ++++++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
index 043d38b..51562d4 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/GenerateRoutes.php
@@ -6,6 +6,7 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Routing\RouterInterface;
@@ -24,8 +25,27 @@ public function __construct(string $projectDirectory, RouterInterface $router)
parent::__construct('fos-routing:generate-symfony');
}
+ protected function configure(): void
+ {
+ $this->addOption(
+ 'name-prefix',
+ null,
+ InputOption::VALUE_REQUIRED,
+ 'Only show routes whose name is starting with this string',
+ );
+ $this->addOption(
+ 'controller-name',
+ null,
+ InputOption::VALUE_REQUIRED,
+ 'Name of the controller to dump',
+ );
+ }
+
protected function execute(InputInterface $input, OutputInterface $output): int
{
+ $namePrefix = $input->getOption('name-prefix');
+ $controllerName = $input->getOption('controller-name');
+
$routes = [];
foreach ($this->router->getRouteCollection() as $name => $route) {
$routeData = $route->__serialize();
@@ -55,11 +75,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
unset($routeData[$key]);
}
}
- $routes[$name] = $routeData;
+
+ if ($this->filterMatches($name, $routeData, $namePrefix)) {
+ $routes[$name] = $routeData;
+ }
}
$targetPath = $this->projectDirectory . '/fos-routing.yaml';
- $output->writleln(Yaml::dump($routes));
+ $output->writeln(Yaml::dump($routes));
$io = new SymfonyStyle($input, $output);
@@ -67,4 +90,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return Command::SUCCESS;
}
+
+ private function filterMatches(string $name, array $data, ?string $namePrefix, ?string $controllerName): bool
+ {
+ if ($namePrefix !== null) {
+ return str_starts_with($name, $namePrefix);
+ }
+
+ if ($controllerName !== null) {
+ return $data['controller'] !== $controllerName;
+ }
+
+ return true;
+ }
}
From a73640b02799f56972c81992c5d1cefbc934f698 Mon Sep 17 00:00:00 2001
From: mamazu <14860264+mamazu@users.noreply.github.com>
Date: Tue, 10 Jun 2025 10:22:46 +0200
Subject: [PATCH 10/23] Remove target path
---
Command/GenerateRoutes.php | 3 ---
1 file changed, 3 deletions(-)
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
index 51562d4..e051656 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/GenerateRoutes.php
@@ -14,12 +14,10 @@
class GenerateRoutes extends Command
{
- private string $projectDirectory;
private RouterInterface $router;
public function __construct(string $projectDirectory, RouterInterface $router)
{
- $this->projectDirectory = $projectDirectory;
$this->router = $router;
parent::__construct('fos-routing:generate-symfony');
@@ -81,7 +79,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}
- $targetPath = $this->projectDirectory . '/fos-routing.yaml';
$output->writeln(Yaml::dump($routes));
$io = new SymfonyStyle($input, $output);
From 29ac5ccc9063ae7089d1b4c6ee6a406518f8deb1 Mon Sep 17 00:00:00 2001
From: mamazu <14860264+mamazu@users.noreply.github.com>
Date: Tue, 10 Jun 2025 10:24:07 +0200
Subject: [PATCH 11/23] Adding description
---
Command/GenerateRoutes.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
index e051656..7209b4d 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/GenerateRoutes.php
@@ -37,6 +37,7 @@ protected function configure(): void
InputOption::VALUE_REQUIRED,
'Name of the controller to dump',
);
+ $this->setDescription('This is a list of all routes in the project. Please copy and paste the relevant routes to your config.');
}
protected function execute(InputInterface $input, OutputInterface $output): int
From 585ab37f6cce774934c6b815a7b4a1cd00da0fba Mon Sep 17 00:00:00 2001
From: mamazu <14860264+mamazu@users.noreply.github.com>
Date: Tue, 10 Jun 2025 10:26:44 +0200
Subject: [PATCH 12/23] Update service config
---
Resources/config/routing.xml | 1 -
1 file changed, 1 deletion(-)
diff --git a/Resources/config/routing.xml b/Resources/config/routing.xml
index 69c4690..5a69932 100644
--- a/Resources/config/routing.xml
+++ b/Resources/config/routing.xml
@@ -55,7 +55,6 @@
- %kernel.project_dir%
From 2b22686a5409724db233a2a85240a393c43c676b Mon Sep 17 00:00:00 2001
From: mamazu <14860264+mamazu@users.noreply.github.com>
Date: Tue, 10 Jun 2025 10:30:05 +0200
Subject: [PATCH 13/23] Using starts with
---
Command/GenerateRoutes.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
index 7209b4d..6289d02 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/GenerateRoutes.php
@@ -91,12 +91,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
private function filterMatches(string $name, array $data, ?string $namePrefix, ?string $controllerName): bool
{
- if ($namePrefix !== null) {
+ if (null !== $namePrefix) {
return str_starts_with($name, $namePrefix);
}
- if ($controllerName !== null) {
- return $data['controller'] !== $controllerName;
+ if (null !== $controllerName) {
+ return str_starts_with($data['controller'], $controllerName);
}
return true;
From e459673e569107d97b4b143dd6599bab10fd013f Mon Sep 17 00:00:00 2001
From: Alexander Schranz
Date: Tue, 10 Jun 2025 11:10:51 +0200
Subject: [PATCH 14/23] Update Command/GenerateRoutes.php
---
Command/GenerateRoutes.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
index 6289d02..5bcdf5d 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/GenerateRoutes.php
@@ -20,7 +20,7 @@ public function __construct(string $projectDirectory, RouterInterface $router)
{
$this->router = $router;
- parent::__construct('fos-routing:generate-symfony');
+ parent::__construct('fos:rest:routing:dump-symfony-routes');
}
protected function configure(): void
From 067ac048cb03d44fa1c32c2a7a1a40853ce50945 Mon Sep 17 00:00:00 2001
From: Alexander Schranz
Date: Tue, 10 Jun 2025 11:11:13 +0200
Subject: [PATCH 15/23] Update Command/GenerateRoutes.php
---
Command/GenerateRoutes.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
index 5bcdf5d..c819836 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/GenerateRoutes.php
@@ -1,7 +1,5 @@
Date: Tue, 10 Jun 2025 11:12:02 +0200
Subject: [PATCH 16/23] Update Command/GenerateRoutes.php
---
Command/GenerateRoutes.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
index c819836..447ddfc 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/GenerateRoutes.php
@@ -14,7 +14,7 @@ class GenerateRoutes extends Command
{
private RouterInterface $router;
- public function __construct(string $projectDirectory, RouterInterface $router)
+ public function __construct(RouterInterface $router)
{
$this->router = $router;
From ff5e0c31ef92a108c95930ffeca1335c391af72b Mon Sep 17 00:00:00 2001
From: Alexander Schranz
Date: Tue, 10 Jun 2025 11:12:43 +0200
Subject: [PATCH 17/23] Update Command/GenerateRoutes.php
---
Command/GenerateRoutes.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
index 447ddfc..e90970a 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/GenerateRoutes.php
@@ -73,7 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}
- if ($this->filterMatches($name, $routeData, $namePrefix)) {
+ if ($this->filterMatches($name, $routeData, $namePrefix, $controllerName)) {
$routes[$name] = $routeData;
}
}
From 2a9f3ddeb1bef20b0a54c9b69cac456d74f8602f Mon Sep 17 00:00:00 2001
From: Alexander Schranz
Date: Tue, 10 Jun 2025 11:13:13 +0200
Subject: [PATCH 18/23] Remove info
---
Command/GenerateRoutes.php | 4 ----
1 file changed, 4 deletions(-)
diff --git a/Command/GenerateRoutes.php b/Command/GenerateRoutes.php
index e90970a..cb1d179 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/GenerateRoutes.php
@@ -80,10 +80,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln(Yaml::dump($routes));
- $io = new SymfonyStyle($input, $output);
-
- $io->info('If you do not like yaml. You can use the symplify/config-transformer package to change it into php.');
-
return Command::SUCCESS;
}
From d2c5484d7bcb183c256802a12177fdffd9bb236b Mon Sep 17 00:00:00 2001
From: Alexander Schranz
Date: Tue, 10 Jun 2025 11:17:29 +0200
Subject: [PATCH 19/23] Add command to readme
---
Command/{GenerateRoutes.php => DumpRoutes.php} | 2 +-
README.md | 18 ++++++++++++++++++
Resources/config/routing.xml | 2 +-
3 files changed, 20 insertions(+), 2 deletions(-)
rename Command/{GenerateRoutes.php => DumpRoutes.php} (98%)
diff --git a/Command/GenerateRoutes.php b/Command/DumpRoutes.php
similarity index 98%
rename from Command/GenerateRoutes.php
rename to Command/DumpRoutes.php
index cb1d179..90add7d 100644
--- a/Command/GenerateRoutes.php
+++ b/Command/DumpRoutes.php
@@ -10,7 +10,7 @@
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Yaml\Yaml;
-class GenerateRoutes extends Command
+class DumpRoutes extends Command
{
private RouterInterface $router;
diff --git a/README.md b/README.md
index 7d3f53d..05075f9 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,24 @@ This bundle provides the automatic route generation for the FOSRestBundle 3.0.
All the installation instructions are located in the [documentation](Resources/doc/1-setting_up_the_bundle.rst).
+
+## Opt-out of the `type: rest` routing
+
+You might want to migrate away from this bundle and use normal Symfony routes.
+Via the command inside this bundle you can convert all `type: rest` routes to normal Symfony routes:
+
+```bash
+bin/console fos:rest:routing:dump-symfony-routes
+
+# filter by a specific controller
+bin/console fos:rest:routing:dump-symfony-routes --controller="your.controller.service"
+
+# filter by a specific name prefix
+bin/console fos:rest:routing:dump-symfony-routes --name-prefix="your_prefix."
+```
+
+Copy the result into a `routing.yaml` file of your choice.
+
## Switching from FOSRestBundle
If you did before using the FOSRestBundle which removed the auto route generation the switch is easy.
diff --git a/Resources/config/routing.xml b/Resources/config/routing.xml
index 5a69932..4304dce 100644
--- a/Resources/config/routing.xml
+++ b/Resources/config/routing.xml
@@ -54,7 +54,7 @@
-
+
From 62b58997ff2d5e3f7717f2a55d269452d9946455 Mon Sep 17 00:00:00 2001
From: Alexander Schranz
Date: Tue, 10 Jun 2025 11:19:09 +0200
Subject: [PATCH 20/23] Update README.md
---
README.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/README.md b/README.md
index 05075f9..49d1f88 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,6 @@ This bundle provides the automatic route generation for the FOSRestBundle 3.0.
All the installation instructions are located in the [documentation](Resources/doc/1-setting_up_the_bundle.rst).
-
## Opt-out of the `type: rest` routing
You might want to migrate away from this bundle and use normal Symfony routes.
From f21caa335aa3df583cd01626d530f0fc89adeedf Mon Sep 17 00:00:00 2001
From: Alexander Schranz
Date: Tue, 10 Jun 2025 11:21:08 +0200
Subject: [PATCH 21/23] Fix ci
---
.github/workflows/test-application.yaml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml
index 01d0e74..ae81fc9 100644
--- a/.github/workflows/test-application.yaml
+++ b/.github/workflows/test-application.yaml
@@ -83,7 +83,7 @@ jobs:
steps:
- name: Checkout project
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Install and configure PHP
uses: shivammathur/setup-php@v2
@@ -96,7 +96,7 @@ jobs:
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
- uses: actions/cache@v2
+ uses: actions/cache@v4
id: composer-cache
with:
path: ${{ steps.composer-cache-dir.outputs.dir }}
@@ -131,7 +131,7 @@ jobs:
steps:
- name: Checkout project
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Install and configure PHP
uses: shivammathur/setup-php@v2
@@ -144,7 +144,7 @@ jobs:
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
- uses: actions/cache@v2
+ uses: actions/cache@v4
id: composer-cache
with:
path: ${{ steps.composer-cache-dir.outputs.dir }}
From c8ca40b66e419d95260ca84dfaa7ae7e1385cc21 Mon Sep 17 00:00:00 2001
From: Alexander Schranz
Date: Tue, 10 Jun 2025 11:23:59 +0200
Subject: [PATCH 22/23] Update DumpRoutes.php
---
Command/DumpRoutes.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/Command/DumpRoutes.php b/Command/DumpRoutes.php
index 90add7d..849c013 100644
--- a/Command/DumpRoutes.php
+++ b/Command/DumpRoutes.php
@@ -6,7 +6,6 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Yaml\Yaml;
From 95a1579c9cdc35618d67c6cf98e24361de56a43a Mon Sep 17 00:00:00 2001
From: Alexander Schranz
Date: Tue, 10 Jun 2025 11:24:05 +0200
Subject: [PATCH 23/23] Update Command/DumpRoutes.php
---
Command/DumpRoutes.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Command/DumpRoutes.php b/Command/DumpRoutes.php
index 849c013..148c264 100644
--- a/Command/DumpRoutes.php
+++ b/Command/DumpRoutes.php
@@ -85,11 +85,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
private function filterMatches(string $name, array $data, ?string $namePrefix, ?string $controllerName): bool
{
if (null !== $namePrefix) {
- return str_starts_with($name, $namePrefix);
+ return 0 === strpos($name, $namePrefix);
}
if (null !== $controllerName) {
- return str_starts_with($data['controller'], $controllerName);
+ return 0 === strpos($data['controller'], $controllerName);
}
return true;