as said, my problem is I get an empty response (looked in firebug) when calling a route on a post method. placing a "die('something')" shows me the action isn't called... I have no idea where the request is handled....
An important thing could be I renamed an entity and all that was related (controllers, forms ...) it works fine except when trying to call Contact -> createAction via my route :
contact_create:
path: /create
defaults: { _controller: "MainMainBundle:Contact:create" }
requirements: { _method: post|put }
I receive empty response.. even if i call it via get method, no error, empty response...
action in controller :
public function createAction(Request $request) { ...
I really dont know if there's something obvious in front of me, and I dont see it, or could it be a kind of routing cache, messing up with the renaming of the routes, controllers, entity...
If anyone has an idea, i'd be very thankul !
regards
EDIT:
contact.yml :
contact:
path: /{companyId}
defaults: { _controller: "MainMainBundle:Contact:index" }
contact_show:
path: /{id}/show
defaults: { _controller: "MainMainBundle:Contact:show" }
contact_new:
path: /new/{companyId}
defaults: { _controller: "MainMainBundle:Contact:new" }
contact_create:
path: /create
defaults: { _controller: "MainMainBundle:Contact:create" }
requirements: { _method: post|put }
contact_edit:
path: /{id}/edit
defaults: { _controller: "MainMainBundle:Contact:edit" }
contact_update:
path: /{id}/update
defaults: { _controller: "MainMainBundle:Contact:update" }
requirements: { _method: post|put }
contact_delete:
path: /{id}/delete
defaults: { _controller: "MainMainBundle:Contact:delete" }
requirements: { _method: post}
contact_revive:
path: /{id}/revive
defaults: { _controller: "MainMainBundle:Contact:revive" }
requirements: { _method: post}
$ php app/console router:debug | grep contact
deal_ajax_load_new_form ANY ANY ANY /deal/dealajaxloadnewform/{contactId}
contact ANY ANY ANY /contact/{companyId}
contact_show ANY ANY ANY /contact/{id}/show
contact_new ANY ANY ANY /contact/new/{companyId}
contact_create POST|PUT ANY ANY /contact/create
contact_edit ANY ANY ANY /contact/{id}/edit
contact_update POST|PUT ANY ANY /contact/{id}/update
contact_delete POST ANY ANY /contact/{id}/delete
contact_revive POST ANY ANY /contact/{id}/revive
Try placing 'contact_create' route on top of contact.yml, I suppose that first route on that file 'contact' is matching with "/create" path (companyId = create) and executing "MainMainBundle:Contact:index" controller instead of "MainMainBundle:Contact:create" one.
Are you using jsrouting-bundle (friendsofsymfony) ? If so, try running the following command
app/console fos:js-routing:dump
Check if you use correct port. In my case port was 8080 but I was using 8000
Related
I am having a little routing problem, here is my code in my controller :
...
else {
return $this->redirectToRoute('index');
}
...
And here is the message I am having :
Unable to generate a URL for the named route "index" as such route does not exist.
And My routing file is :
front_signup:
path: /signup
defaults: { _controller: FrontBundle:signup:inscription }
front_index:
path: /index
defaults: { _controller: FrontBundle:index:acceuil }
front_login:
path: /login
defaults: { _controller: FrontBundle:login:connection }
Thanks for any help.
I have URL error:
link rel="alternate" type="application/atom+xml" title="Latest Jobs"
href="{{ url('job', {'_format': 'atom'}) }}" />
Routing.yml file:
job_job:
resource: "#JobBundle/Resources/config/routing/job.yml"
prefix: /job
job_homepage:
path: /
defaults: { _controller: JobBundle:Default:index }
This what my job.yml contains -
(I use in path "job_homepage" , in url I use "job" , but when I'm trying to run show action or edit action it work correctly)
job_index:
path: /
defaults: { _controller: "JobBundle:Job:index" }
methods: GET
job_show:
path: /{id}/show
defaults: { _controller: "JobBundle:Job:show" }
methods: GET
job_new:
path: /new
defaults: { _controller: "JobBundle:Job:new" }
methods: [GET, POST]
job_edit:
path: /{id}/edit
defaults: { _controller: "JobBundle:Job:edit" }
methods: [GET, POST]
job_delete:
path: /{id}/delete
defaults: { _controller: "JobBundle:Job:delete" }
methods: DELETE
I use http://127.0.0.1:8000/job/ to run my project
You dont have a route for job in your routing file.
Should be something like:
link rel="alternate" type="application/atom+xml" title="Latest Jobs" href="{{ url('job_homepage', {'_format': 'atom'}) }}" />
Or if you have different named routes in "#JobBundle/Resources/config/routing/job.yml" use one of those. But the error is pretty clear, you dont have a route named job
I have an application in symfony2, and i create routing like this:
spec_add:
path: /add.html
defaults: { _controller: MyBundle:Spec:add }
methods: [GET, POST]
spec_add_to_order:
path: /{indent}/add.html
defaults: { _controller: MyBundle:Spec:add }
methods: [GET, POST]
requirements:
indent: \d+
spec_edit:
path: /{id}/edit.html
defaults: { _controller: MyBundle:Spec:add }
methods: [GET, POST]
requirements:
id: \d+
And I have controller SpecController and method:
public function addAction(Indent $indent = null,Specification $specification = null, Request $request)
when I go to address mydomain.dev/{myindentId}/add.html
i get indent object but I get Specification object too, Why? i don't want specification in this case what am I doing wrong?
i have a very simple understanding question
isnt it possible to have such routing patterns ?
foobar_foobar_videos_all:
pattern: /video
defaults: { _controller: foobarfoobarBundle:Content:showVideos }
foobar_foobar_videos_by_category:
pattern: /video/{category}
defaults: { _controller: foobarfoobarBundle:Content:showVideosByCategory }
foobar_foobar_videos_by_category_and_offset:
pattern: /video/{category}/page/{offset}
defaults: { _controller: foobarfoobarBundle:Content:showVideosByCategory }
this way the first route doesnt work, printing
"No route found for "GET /video"
while the others work perfect.
How can i route to /video ?
The solution was to put it the /video pattern to the end
foobar_foobar_videos_by_category:
pattern: /video/{category}
defaults: { _controller: foobarfoobarBundle:Content:showVideosByCategory }
foobar_foobar_videos_by_category_and_offset:
pattern: /video/{category}/page/{offset}
defaults: { _controller: foobarfoobarBundle:Content:showVideosByCategory }
foobar_foobar_videos_all:
pattern: /video
defaults: { _controller: foobarfoobarBundle:Content:showVideos }
So I've decided to delve into phpunit testing and I've shamefully written out my php code before writing my test. Anyway, I'm just writing a very simple test that tells me if I actually found the correct web page. Unfortunately my one assertion test keeps failing. I know my route "/login" is correct because when I navigate to localhost/index.php/login (where index.php is a link to app_dev.php), the page comes up correctly. Bellow is my routing.php file:
caremonk_mainsite_login:
pattern: /login
defaults: { _controller: CaremonkMainSiteBundle:Security:login }
requirements:
_method: POST|GET
caremonk_mainsite_login_check:
pattern: /login_check
requirements:
_method: POST|GET
caremonk_mainsite_signup:
pattern: /signup
defaults: { _controller: CaremonkMainSiteBundle:CreateUser:signup }
requirements:
_method: POST|GET
caremonk_mainsite_logout:
pattern: /logout
defaults: { _controller: CaremonkMainSiteBundle:Security:logout}
requirements:
_method: POST|GET
caremonk_mainsite_post_blog:
pattern: /post_blog
defaults: { _controller: CaremonkMainSiteBundle:UserEvents:post }
requirements:
_method: POST|GET
caremonk_mainsite_my_profile:
pattern: /my_profile_edit
defaults: { _controller: CaremonkMainSiteBundle:UserEvents:editProfile }
requirements:
_method: POST|GET
caremonk_mainsite_activate:
pattern: /activate/{username}/{token}
defaults: { _controller: CaremonkMainSiteBundle:CreateUser:activateAccount }
requirements:
_methods: GET
caremonk_mainsite_password_reset_request:
pattern: /reset_password/
defaults: { _controller: CaremonkMainSiteBundle:Security:passwordResetRequest }
requirements:
_methods: GET | POST
caremonk_mainsite_reset_password_email:
pattern: /reset_password_email/{username}/{resetPasswordToken}
defaults: { _controller: CaremonkMainSiteBundle:Security:sendNewPassword }
requirements:
_methods: GET
caremonk_mainsite_change_password:
pattern: /change_password
defaults: { _controller: CaremonkMainSiteBundle:Security:changePassword }
requirements:
_methods: GET | POST
caremonk_mainsite_home:
pattern: /
defaults: { _controller: CaremonkMainSiteBundle:Home:index }
requirements:
_methods: GET
Anyway bellow is the test code that keeps failing:
<?php
namespace Caremonk\MainSiteBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class SecurityControllerFunctionalTest extends WebTestCase
{
public function testIndex()
{
$client = static::createClient();
// I've done many tests
// I've tried the following request with all failed results
// $crawler = $client->request('GET', 'index.php/login');
// $crawler = $client->request('GET', 'http://localhost/indpex.php/login');
// $crawler = $client->request('GET', 'localhost/index.php/login');
// You get the idea
$crawler = $client->request('GET', '/login');
$this->assertTrue($client->getResponse()->isSuccessful());
}
}
My routing.yml and routing_dev.yml files are shown bellow
#routing_dev.yml
_wdt:
resource: "#WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "#WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_configurator:
resource: "#SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
prefix: /_configurator
_main:
resource: routing.yml
#routing.yml
caremonk_main_site:
resource: "#CaremonkMainSiteBundle/Resources/config/routing.yml"
prefix: /
You prefixed your imported routes with a "/", and your routes path start with a "/".
Normally I would prefix my routes with something more meaningful (and does not end with a "/") or remove the "/" from your imported routes.
Running the following command should give you insight to how your routes are registered.
app/console debug:router