Category: symfony5

Symfony 5 Functional Tests – Environment Variables missing, getenv() returns false

I was rewriting one of my projects into Symfony 5. I’ve noticed something strange about env variables. I can’t get them anymore the way I used to be able to get them in the functional tests. Not that it matters…

Is there a way to pass callbacks as constructor arguments in Symfony YAML files?

For the CI environment I overwrite responses of the HTTP client. This works: symfony.mock_http_response: class: SymfonyComponentHttpClientResponseMockResponse arguments: – ‘{ "data": "some response data" }’ SymfonyContractsHttpClientHttpClientInterface: class: SymfonyComponentHttpClientMockHttpClient arguments: – ‘@symfony.mock_http_response’ However I like to choose the dynamic approach with callback,…

LDAP and Symfony : Could not complete search with dn

I try to pass my application to Symfony. I have a problem with authentication. With PHP, I used this code to check connection to active directory $ldap_host = "%MY AD HOST%"; $ldap_dn = cn=srv_ldap,ou=Service,ou=Applicatifs,ou=Utilisateurs,ou=DomaineInterne,dc=mydomain,dc=pri"; $ldap_usr_dom = ‘@mydomain.pri’; $ldap = ldap_connect($ldap_host);…

Symfony 5 security.interactive_login event not called

I want to use the security.interactive_login event to update my User’s last login field. The event is successfully registered: php bin/console debug:event-dispatcher security.interactive_login Registered Listeners for "security.interactive_login" Event =========================================================== ——- ———————————————————————— ———- Order Callable Priority ——- ———————————————————————— ———- #1 AppEventSubscriberUserLocaleSubscriber::onSecurityInteractiveLogin()…

Symfony Exception Subscriber not triggered

I need to format error messages and output it in JSON format. I have the following event subscriber: namespace AppEventSubscriber; use SymfonyComponentEventDispatcherEventSubscriberInterface; use SymfonyComponentHttpKernelEventExceptionEvent; use SymfonyComponentHttpKernelKernelEvents; final class ExceptionSubscriber implements EventSubscriberInterface { public static function getSubscribedEvents(): array { return [KernelEvents::EXCEPTION…

getUser method from Symfony Security can’t get my User Repository

My problem is the $this->getUser(); method (called from Controller) from Symfony Security can’t get my User Repository. The "AppModelODMRepositoryUserRepository" document repository implements "DoctrineBundleMongoDBBundleRepositoryServiceDocumentRepositoryInterface", but its service could not be found. Make sure the service exists and is tagged with "doctrine_mongodb.odm.repository_service"….

Symfony 5.1.3 Issue while clearing the cache: Attempted to load class "MappingDriverChain" from namespace

I have updated my symfony application to 5.1.3. But since then there is a class missing exception on clearing the cache. In App_KernelDevDebugContainer.php line 1050: Attempted to load class "MappingDriverChain" from namespace "DoctrineCommonPersistenceMappingDriver". Did you forget a "use" statement for…