Symfony2 returns No route found for "GET /Categoria/" when I try to access to localhost/Symfony/web/app_dev.php/Categoria/, the page localhost/Symfony/web/app_dev.php/hello/Guido works.
src\grupo85\entregaFinalBundle\Resources\config\routing.yml:
grupo85entrega_final_homepage:
pattern: /hello/{name}
defaults: { _controller: grupo85entregaFinalBundle:Default:index }
app\config\routing.yml:
grupo85entrega_final:
resource: "#grupo85entregaFinalBundle/Resources/config/routing.yml"
prefix: /
grupo85entregaFinalBundle:
resource: "#grupo85entregaFinalBundle/Controller/"
type: annotation
prefix: /
php app/console route:debug
categoria GET ANY ANY /categoria/
categoria_create POST ANY ANY /categoria/
categoria_new GET ANY ANY /categoria/new
categoria_show GET ANY ANY /categoria/{id}
categoria_edit GET ANY ANY /categoria/{id}/edit
categoria_update PUT ANY ANY /categoria/{id}
categoria_delete DELETE ANY ANY /categoria/{id}
I've also tried to run the cache:clear --env prod command and remove pp/cache folder manually.
What's wrong?
Thanks.
Please understand error message. You have not route for /Categoria/. You have route for /categoria/. Please notice lower case. SF2 router recognizes lower and upper cases.
Related
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
I set my route files in my Symfony2.5 project. But i have this problem when I launched my application with Wamp server (localhost on Windows):
No route found for "GET /" (from "http://localhost/girSymfony/web/")
404 Not Found - NotFoundHttpException
1 linked Exception: ResourceNotFoundException »
This is the url used when the application is lauched on WampServer: http://localhost/girSymfony/web/
When I tried with this URL http://localhost/girSymfony/web/I have the 404 error as mentioned above.
But if I try with this url: http://localhost/girSymfony/web/gir/homepage it works; I would like the application arrive and run directly on this url. How can i do that?
This is my Gir/WelcomeBundle/Ressource/config/routing.yml file code:
girWelcomeBundle_HomePage:
pattern: /homepage
defaults: { _controller: GirWelcomeBundle:HomePage:index }
requirements:
methods: GET
schemes: https
And this my app/config/routing.yml file code:
GirWelcomeBundle:
resource: "#GirWelcomeBundle/Resources/config/routing.yml"
prefix: /gir
And here's my controller code for Gir/WelcomeBundle/Controller/HomePageController.php:
<?php
namespace Gir\WelcomeBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class HomePageController extends Controller
{
public function indexAction()
{
return $this->render('GirWelcomeBundle:HomePage:index.html.twig');
}
}
Like you can see, I set the routes files, but I just forgot something because I have the 404 error.
I think my application don't use the right direction and the right URL , how can I fix it ?
New edit: Note that I 've set WAMP and Symfony in order when I run my application I arrive directly on the HomePage index
You are on development environemt , you should have to use url like this
Example:
registration:
pattern: /registration
defaults: { _controller: UserBundle:Registration:registration }
http://localhost/girSymfony/web/app_dev.php/registration
In file: HardCoreMore/HRAPIBundle/Resources/config/routing.yml
I have imported route like this:
hr_api_company:
resource: "#HRAPIBundle/Resources/config/routing/company.yml"
prefix: /company
And in file: HardCoreMore/HRAPIBundle/Resources/config/routing/company.yml
I have defined route for creating company like this:
hardcoremore_hr_api_company_create:
pattern: /
defaults: { _controller: HRAPIBundle:Company:create }
methods: [POST]
Now the route is matched with following url:
POST company/
but it is not matched when I called it with:
POST company
How can I define route without ending slash when importing route and prefixing it?
this is not possible, see : https://github.com/symfony/symfony/issues/4322
I hope this has helped
I have followed the instructions here:
http://symfony.com/doc/current/components/routing/hostname_pattern.html
To make the route based on the host. However I want to use parameters instead of hard coding. The documentation says you can use service parameters, but I seem to be having trouble getting the parameters to work.
Here is the code from routing.yml:
rc_course_new:
pattern: /course/new
host: "{ domain }"
defaults: { _controller: CoursesRCWizardBundle:Wizard:new }
requirements:
domain: "%rc_domain%"
And here is the code from services.yml:
parameters:
rc_domain: my.domain.com
I get this error (looks like it is not picking up the parameter but seeing it as a hard code):
Oops! Google Chrome could not find { domain }
Managed to fix this:
In the routing:
rc_course_new:
pattern: /course/new
host: "%rc_domain%"
defaults: { _controller: CoursesRCWizardBundle:Wizard:new }
In the services (might work better in the parameters file) file:
parameters:
rc_domain: my.domain.com
I'm doing a bundle with google drive api that lists files. I have in the IndexAction an if that sees if the user needs to give permission or already gave. If needs, then I get the url from google and redirect to that link.
In google console I put as redirect link:
www.googlebundle/firstTime
In my GoogleDriveController I've got the
public function firstTimeAction() {
(...)
}
And in my routing I got this:
FilesGoogleDriveBundle_firstTime:
pattern: /firstTime
defaults: { _controller: "FilesGoogleDriveBundle:GoogleDrive:firstTime" }
requirements: { _method: get }
FilesGoogleDriveBundle_homepage:
pattern: /Drive/{id}
defaults: { _controller: FilesGoogleDriveBundle:GoogleDrive:index }
But I get this error in prod.log:
[2012-11-26 16:50:14] request.ERROR: Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route found for "GET /firstTime" (uncaught exception) at /var/www/Symfony/app/cache/prod/classes.php line 4564 [] []
Does anyone know what's happening?
First make sure that symfony see your router rule.
In project root directory put
php app/console router:debug | grep FilesGoogleDriveBundle_firstTime
You should get something like this
FilesGoogleDriveBundle_firstTime GET /firstTime
The last value is the URL for this action.
FilesGoogleDriveBundle_firstTime:
pattern: /firstTime
defaults: { _controller: FilesGoogleDriveBundle:GoogleDrive:firstTime }
requirements:
_method: GET
Try this.
seems like a cache problem, clear the cache for the prod environment:
php app/console cache:clear --env=prod