Routing
This section is deprecated. However, as of now, the Sylius E-Commerce project is still resorting to this configuration so you might want to check it out.
SyliusResourceBundle ships with a custom route loader that can save you some time.
Generating Generic CRUD Routing
To generate a full CRUD routing, simply configure it in your config/routes.yaml:
Results in the following routes:
php bin/console debug:router------------------------ --------------- -------- ------ -------------------------
Name Method Scheme Host Path
------------------------ --------------- -------- ------ -------------------------
app_book_index GET ANY ANY /books/
app_book_create GET|POST ANY ANY /books/new
app_book_update GET|PUT|PATCH ANY ANY /books/{id}/edit
app_book_show GET ANY ANY /books/{id}
app_book_bulk_delete DELETE ANY ANY /books/bulk-delete
app_book_delete DELETE ANY ANY /books/{id}Using a Custom Path
By default, Sylius will use a plural form of the resource name, but you can easily customize the path:
Results in the following routes:
Generating API CRUD Routing
To generate a full API-friendly CRUD routing, add these YAML lines to your config/routes.yaml:
Results in the following routes:
Excluding Routes
If you want to skip some routes, simply use except configuration:
Results in the following routes:
Generating Only Specific Routes
If you want to generate only some specific routes, simply use the only configuration:
Results in the following routes:
Generating Routing for a Section
Sometimes you want to generate routing for different "sections" of an application:
Last updated
Was this helpful?
