I'm using FOSUserBundle (the same problem on 0.12.0 and current dev-master) with Symfony 2.3.
I have problem with PATCH methods.
Simple example:
public function patchAction($slug)
{
[...]
return $view;
}
I see proper route was generated in php app/console router:debug:
api_patch_user PATCH ANY ANY /api/users/{slug}.{_format}
But when I am making request, I'm getting:
501 - Not implemented
When I change only method name to i.e. DELETE everything is working. So the problem is only with PATCH type requests.
Related
My Symfony 3.4 project does not recognize any route anymore. Debugging routes in terminal (php bin/console debug:router) does show all the routes but app_dev.php keeps giving error messages. Routing is enabled and set correct in routing.yml file.
Clearing cache also did not work.
mail_chimp:
resource: "#MailChimpBundle/Controller/"
type: annotation
prefix: /
/**
* #Route("/klanten/lijst")
*/
public function klantenLijstAction() {
return;
}
screenshot
Thanks.
> the routing tries to match routes one by one in the order of their definitions; whenever one matches, work is done.
In the routes-list image, you look to have three (maybe more) routes to answer the URL '/'. Which single one should run a controller action?
You should probably set prefixes for the URLs that aren't the index route.
Have looked through SO at various Symfony routing issues but no-one seems to have the same issue as this.
Yesterday, routing worked without issue.
Today I am getting errors regarding values being required for arguments with defaults set
This is an example route that is causing me a problem
#Route("/summary/{staffId}", name="task_instance_summary", requirements={"staffId":"\d+"},defaults={"staffId":"0"})
The method definition:
public function summaryAction(Request $request, $staffId)
and of course the error:
"Controller "PlanXL\TaskBundle\Controller\InstanceController::summaryAction()" requires that you provide a value for the "$staffId" argument (because there is no default value or because there is a non optional argument after this one).")
Debug output:
[router] Route "task_instance_summary"
Name task_instance_summary
Path /task/instance/summary/{staffId}
Path Regex #^/task/instance/summary(?:/(?P\d+))?$#s
Host ANY
Host Regex
Scheme ANY
Method ANY
Class Symfony\Component\Routing\Route
Defaults _controller: PlanXLTaskBundle:Instance:summary
staffId: 0
Requirements staffId: \d+
Options compiler_class: Symfony\Component\Routing\RouteCompiler
I have already cleared the cache (even though I am working on dev) but I can't see why I am getting an error. The router can obviously see the default value when I run the debug so why not when called through my application?
Try it;
public function summaryAction(Request $request, $staffId = 0)
I am implementing a SYMFONY 3 project in production mode for the first time.
I follow OceanDigital tutorial and the standard doc.
I went thru a bunch of issues linked to user writing rights that I've solved, and I do get now a SYMFONY ERROR page (one step closer to victory) with this message:
Unable to find template "MyBundle:std_page:home.html.twig" (looked
into: /[folder to symf project]/app/Resources/views,
/[folder to symf project]/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form,
/[folder to symf project]/vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views).
If I look in my [my symf project]\app\config\routing.yml, I have:
my_bundle:
resource: "#MyBundle/Resources/config/routing.yml"
options:
expose: true
In [my symf project]\app\AppKernel.php, in the registerBundles() function, I have:
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
....
new MyBundle\MyBundle(),
.....
]
}
}
And the file regarding the template that should be fetched [my symf project]\src\MyBundle\Ressources\views/std_page/home.html.twig exists.
What did I not set up right, in production mode, to have it looking for the TWIG template in the folder [my symf project]\src\MyBundle\Ressources\views/?
After some search it happens to be a mistake similar to the one described in that SO thread.
In my controller I had:
return $this->render('MyBundle:Std_page:home.html.twig',$parameters);
Instead of:
return $this->render('MyBundle:std_page:home.html.twig',$parameters);
The development was made on a WINDOWS 10 OS, and it is set up in production on a UBUNTU 16.04. It seems that UBUNTU is stricter than WINDOWS regarding the letter case.
I have got a strange problem with routing in Symfony 3.0
My controller code looks like this:
/**
* #Route("/dokumenty/plik/{dok_id}/{plik_id}", defaults={"plik_id" = "nowy"}, name="dokument_plik")
* #Security("has_role('ROLE_USER')")
*/
but whenever I try to access /dokumenty/plik/1/ or /dokumenty/plik/1/1/ I get the routing error:
No route found for "GET /dokumenty/plik/1/"
I have tried to debug the routing from console using php bin/console debug:router and I got inter alia the following route listed
dokument_plik ANY ANY ANY /dokumenty/plik/{dok_id}/{plik_id}
At the same time when I use php bin/console router:match dokumenty/plik/1/1/ i get:
[ERROR] None of the routes match the path "dokumenty/plik/1/1/"
At results of both commands seems contradictory I am a little confused.
Its about last slash. Try /dokumenty/plik/1
I am trying to get FOSElasticaBundle to work.
ElasticSearch Instance is running on localhost:9200 and responding.
I followed each step in the docs https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/master/Resources/doc/setup.md
but at the last step, I get this error in my console:
c:\xampp\htdocs\my\folder>php app/console fos:elastica:populate
Resetting app
Fatal error: Wrong parameters for Exception([string $exception [, long $code [,
Exception $previous = NULL]]]) in C:\xampp\htdocs\my\folder\vendor\rufli
n\elastica\lib\Elastica\Exception\ResponseException.php on line 34
[Symfony\Component\Debug\Exception\FatalErrorException]
Error: Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]])
fos:elastica:populate [--index[="..."]] [--type[="..."]] [--no-reset] [--offset="..."] [--sleep="..."] [--batch-size="..."] [--ignore-errors] [--no-overwrite-format]
It seems like there are 3 parameters mandatory for "__construct"-Function, but there are only 2 of them. I've simply tried to add "NULL"-parameter to get it work, but then another function throws an error.
public function __construct(Request $request, Response $response)
{
$this->_request = $request;
$this->_response = $response;
parent::__construct($response->getError());
}
Is this a common problem? How do I solve it?
This is because the ruflin/Elastica package is not compatible with elasticsearch 2.0 yet.
https://github.com/ruflin/Elastica/issues/946
An alternative for now (until ruflin/Elastica is 2.0 upgraded), is to use the latest 1.x version.
You can download it here: https://www.elastic.co/downloads/past-releases/elasticsearch-1-7-3
ES 1.7.3 + FosElasticaBundle (which uses ruflin/Elastica) works fine with Elasticsearch 1.7.3 version.
The reason for this issue is, that with elasticsearch 2.0 the structure of the response error changed (more details here: https://github.com/ruflin/Elastica/issues/946). Instead of a string before it is now a nested array. Elastica is currently not yet fully compatible with elasticsearch 2.0. As soon as a new release of Elastica is out which is compatible with Elasticsearch 2.0 it will probably mean that also foselastica bundle will have to be updated as these changes will break backward compatibility. Be also aware, that this is not the only backward compatibility breaking change.
To follow the progress of the upgrade, follow this issue: https://github.com/ruflin/Elastica/issues/946