I have a little external library that expose many classes. Into my symfony4 project I would like to declare my class from vendor, as a service with autowire and public. So I have include my library …
Tag: symfony
Symfony 4 – controllers in two directories
In my application, I use Symfony 4. I want Symfony to search for controllers in two directories: A and B. I found something like this: controllers: resource: ‘../src/DirectoryA/Controller/’ …
File not found exception on Symfony upload
I’m using Symfony 3.4 to work on a simple REST API microservice. There are not much resources to be found when working with HTTP APIs and file uploads. I’m following some of the instructions from the …
Manually switch _locale in symfony 4
I’m absolutely stuck in getting a solution to manually switch the _locale variable in Symfony 4. I followed these steps, but now I have absolutely no idea how to make a simple switch button in the nav section. I also took a look a this question, but this seems to be an older Symfony version.. Can anyone please help me
How to test a Symfony BinaryFileResponse with php-unit
I have written an action which create a temporary file and returned it with a BinaryFileResponse and delete it after. Something like this : $response = new BinaryFileResponse($this->getFile($…
Symfony 4 : Override public services in container
I am migrating our project to Symfony 4. In my test suites, we used PHPUnit for functional tests (I mean, we call endpoints and we check result). Often, we mock services to check different steps. Since I migrated to Symfony 4, I am facing this issue: SymfonyComponentDependencyInjectionExceptionInvalidArgumentException: The “my.service” service is already initialized, you cannot replace it. when we redefine
Google Indexing API – 403 ‘Forbidden Response’
I am making a call to the google indexing API for job postings: When making the call to the API, the response given is ‘403 – Forbidden’ . Any ideas what this error actually means? I have created the service account correctly but cannot replicate success from my dev enviroment. Answer Make sure that you have added the service account
Symfony 4 – Autowiring not working
I have a form that write values to an specific Entity, and I am trying to edit the information through a function in the controller, pretty simple. BancoController.php The problem is, when I access /banco/{id}, I get the error: My service.yaml is all default, so I guess it should work automatically. The entities doesn’t show in bin/console debug:container. If I
How to compare value of the form before and after submitting in Symfony?
I am using symfony 3.4.8 version. When I am updating form data I want to see the differences before submit and after submit. After $formEdit->handleRequest($request); line old value is changing to the new value but I don’t want it. but I could not do this. Here is my controller. Answer In php, objects are passed by reference. Have a look
Could not find any fixture services to load
i know this question has been asked already multiple times: Symfony 3.4 and Fixtures Bundle issue with bundle version 3.0 Symfony 3.4.0 Could not find any fixture services to load Symfony Doctrine …