I need to add a requirement for my api route (only allow 3 mgn , user and adm) but i get the error:
MissingMandatoryParametersException
Some mandatory parameters are missing ("role") to generate a URL for route "api_doc".
here is my route:
api_platform:
resource: .
type: api_platform
prefix: /{role}/api
requirements:
role: "mng|adm|user"
should i install or set something?, thank you
already find a solution
if some person need it
api_platform:
resource: .
type: api_platform
prefix: /{app}/api
defaults:
app: take|mngr|drvr
requirements:
app: take|mngr|drvr
thank you
Related
I made an api with api-platform.
I tried to edit the swagger_ui path '/' to '/docs' according to api-platform documentation and allow '/' redirect to custom twig i made.
The swagger_ui documentation is available in /docs path but also still available in '/' path instead of my custom twig file.
Here is my config :
app/config/packages/api_platform.yaml
api_platform:
mapping:
paths: ['%kernel.project_dir%/src/Entity']
enable_swagger_ui: true
enable_re_doc: true
enable_docs: true
app/config/routes/api_platform.yaml
api_platform:
resource: .
type: api_platform
prefix: /
app/config/route.yaml
swagger_ui:
path: /docs
controller: api_platform.swagger.action.ui
hello-world:
path: /
controller: App\Controller\HelloController::index
Thanks by advance for your answer, if i haven't be clear, just le me know :)
Try changing
api_platform:
mapping:
paths: ['%kernel.project_dir%/src/Entity']
enable_swagger_ui: true
enable_re_doc: true
enable_docs: true
with
api_platform:
mapping:
paths: ['%kernel.project_dir%/src/Entity']
enable_swagger_ui: true
enable_re_doc: true
enable_docs: true
and pay attention to indentation in other files ...
This seems to be broken for now. There's a PR to fix the issue inside Api Platform but it hasn't been merged yet: https://github.com/api-platform/core/pull/2749
I'm using annotations in my project but to redirects using routes.yaml
If exists routing (ex. /home name="home"} that redirect not working:
home-301:
path: /home
defaults:
_controller: FrameworkBundle:Redirect:urlRedirect
path: /new-home
permanent: true
I found solution but I thing it is no good practice:
cleared: config/routes/annotations.yaml
and appended to the end of the file config/routes.yaml:
controllers:
resource: ../../src/Controller/
type: annotation
how to do it right?
My solution:
all redirects put in: config/routers/redirects.yaml
and config/routes.yaml:
redirects:
resource: routes/redirects.yaml
annotations:
resource: routes/annotations.yaml
I configure a symfony 2.7 installation with the lasted sonata admin and sonata user bundles. My backend work well, also work /profile page, but I'm getting this error in /profile/edit-profile and /profile/edit-authentication :
Unable to find template "MopaBootstrapBundle:Form:fields.html.twig" in SonataUserBundle:ChangePassword:changePassword_content.html.twig at line 2.
this is my config.yml
fos_user:
...
profile:
form:
type: fos_user_profile
handler: fos_user.profile.form.handler.default
name: fos_user_profile_form
validation_groups: [Authentication]
sonata_user:
...
profile: # Profile Form (firstname, lastname, etc ...)
form:
type: sonata_user_profile
handler: sonata.user.profile.form.handler.default
name: sonata_user_profile_form
validation_groups: [Profile]
and some routes:
sonata_user_resetting:
resource: "#SonataUserBundle/Resources/config/routing/sonata_resetting_1.xml"
prefix: /resetting
sonata_user_profile:
resource: "#SonataUserBundle/Resources/config/routing/sonata_profile_1.xml"
prefix: /profile
sonata_user_change_password:
resource: "#SonataUserBundle/Resources/config/routing/sonata_change_password_1.xml"
prefix: /profile
Also look for that template mention in that twig file but I don't see it.
Any help will be apreciated.
Finally I find the solution installing mopa bootsrap bundle and configure it.
Let's say I've got a website with multiple (sub)domains:
acme.com (USA)
acme.nl (Netherlands)
be.acme.eu (Belgium)
de.acme.eu (Germany)
fr.acme.eu (France)
etc...
I thought this should be very simple to configure, so I made this routing.yml:
usa:
host: "acme.com"
resource: "#WebsiteBundle/Controller/"
type: annotation
defaults:
country: "en"
netherlands:
host: "acme.nl"
resource: "#WebsiteBundle/Controller/"
type: annotation
defaults:
country: "nl"
europe:
host: "{country}.acme.eu"
resource: "#WebsiteBundle/Controller/"
type: annotation
But if I run router:debug, only the last route (in this case {country}.acme.eu) shows up. If I change to order, the last option shows up.
How can I use different (sub)domains for all my countries?
This is because all the routes point to one resource. Every later route will override routes defined before.
But you can use another solution:
main_route:
host: "{country}.acme.{domain}"
resource: "#WebsiteBundle/Controller/"
type: annotation
defaults:
country: "en"
Then check in some listener before controller for valid url and process parameters.
You should use Symfony's hostname routing.
So your routes would look like:
international_homepages:
path: /
host: "{subdomain}.acme.{extension}"
defaults:
_controller: AcmeBundle:Main:defaultHomepage
subdomain: www
extension: com
I have my app setup to use 3 subdomains, I also have 2 domains that point to the same app, giving me this set of FQDNs
admin.domain1.com, admin.domain2.com
www.domain1.com, www.domain2.com
kiosk.domain1.com, kiosk.domain2.com
In routing.yml I can set up the host / resource keys to point those domains at the relevant bundle, but I can only do it for one of the domains at a time.
incompass_admin:
host: admin.domain1.com
resource: "#IncompassAdminBundle/Resources/config/routes.yml"
incompass_web:
host: www.domain1.com
resource: "#IncompassWebBundle/Resources/config/routes.yml"
incompass_kiosk:
host: kiosk.domain1.com
resource: "#IncompassKioskBundle/Resources/config/routes.yml"
When I try something like this
incompass_kiosk_1:
host: kiosk.domain1.com
resource: "#IncompassKioskBundle/Resources/config/routes.yml"
incompass_kiosk_2:
host: kiosk.domain2.com
resource: "#IncompassKioskBundle/Resources/config/routes.yml"
The second domain is the only one that is recognised, kiosk.domain1.com throws an exception: No route found for "GET /"
Is there a way to either set the domain as a wildcard in routing.yml, or to point 2 different routes to the same resource?
edit: I've also tried to have
IncompassKioskBundle/Resources/config/routes_1.yml
IncompassKioskBundle/Resources/config/routes_2.yml
and
IncompassKioskBundle/Resources/config/routes.yml
IncompassRoutingBundle/Resources/config/kiosk_routes.yml
where the names of the routes in the 2 files are different e.g.
// routes.yml
domain_one_kiosk_scanning:
type: annotation
prefix: /
resource: Incompass\KioskBundle\Controller\ScanningController
domain_one_kiosk_printing:
type: annotation
prefix: /print
resource: Incompass\KioskBundle\Controller\PrintingController
// kiosk_routes.yml
domain_two_kiosk_scanning:
type: annotation
prefix: /
resource: Incompass\KioskBundle\Controller\ScanningController
domain_two_kiosk_printing:
type: annotation
prefix: /print
resource: Incompass\KioskBundle\Controller\PrintingController
That did not work.
You can use placeholders in routes, so try something like this:
incompass_kiosk:
host: "kiosk.{domain}.com"
resource: "#IncompassKioskBundle/Resources/config/routes.yml"
requirements:
domain: domain1|domain2
defaults: { domain: domain1 }
You could alternatively handle this in your .htaccess or virtual host configuration.