Apply a filter on a SonataAdmin List
I have a backoffice under SonataAdmin and a ForumAdmin class and this class defines a list of fields that are shown in the Forum List template.Something like that : protected function...
View ArticleSymfony validation doesnt' work with Api Platform and action class
I'm using symfony 4 and Api Platform 2.5 . I have created a custom operation to change user password.The problem is that when I send an empty oldPassword or any other required attributes,the validation...
View ArticleFatal error: Uncaught Twig\Error\LoaderError
I have just deployed my application on the server. If I use APP_ENV=dev, everything works fine but if I use APP_ENV=prod, I get the following error:Fatal error: Uncaught Twig\Error\LoaderError: The...
View ArticleCannot execute bin/console doctrine:migrations:migrate RuntimeException...
I am deploying my Symfony 4 app to the production environment for the first time using rsync.I then try to run the doctrine:migrations:migrate command.php -v : PHP 5.6.40CentOS: 7.6EasyApache4When I...
View ArticleSwiftmailler through Proxy
In my development env I did this small code to test to send emails.$message = (new \Swift_Message('Hello Email')) ->setFrom('sendTest@mysender.com') ->setTo('myEmail@gmail.com')...
View Articlemonolog catch Fatal Error: Allowed memory size exhausted
I would like to know how I can make monolog for symfony 4 logging fatal errors: PHP Fatal error: Allowed memory size of xxxx exhausted to the main log handler.In my application these errors are logged...
View ArticleSymfony 5 pass parameter to logout / login functions
In a Symfony 5.0 Application I have the following scenario:An admin user is able to create new users. If a new user is created in that way I want to log out the admin redirect to the login screen and...
View ArticleSymfony validation doesnt' work with Api Platform when using custom action class
I'm using symfony 4 and Api Platform 2.5 . I have created a custom operation to change user password.The problem is that when I send an empty oldPassword or any other required attributes,the validation...
View ArticleSymfony 4 - cannot find all migration versions
I am trying to run migrations on a Symfony 4 application with a total of 271 migrations. However, when doing so it skips the first 41 migrations (the first is Version20180921083101).>>> php...
View ArticleSymfony Easyadmin - How to open modal on custom action
I'm trying to create a custom action with the type 'route'. But I want to display a confirmation modal before doing the request. For example, in the list view, I want to have the actions: edit, view...
View ArticleSymfony 5 preserve session attribute after user logout
In https://symfony.com/doc/current/session.html it is said that "Stored attributes remain in the session for the remainder of that user's session."Is there a way to keep session attributes when the...
View ArticleCreate a session from API
My frontend is on example.com and my backend is on api.example.com.I am using this line to set a session:$this->get('session')->set('id', 1); I can get the value of that session by...
View ArticleSession can not be saved
From one function I am setting a session and from another function, I would like to get the value of that session.// Set the session public function setSession($data) {...
View ArticleSymfony / Doctrine : problem with an entity ManyToOne to OneToOne
I'm having troubles with my Users entity.In my website, users can fill their collection to keep track of their Magic the gathering cards. Every users have one and only one collection. So, I created a...
View ArticleHow to add role on user during the session
I just updated Symfony 4.3 to 4.4 and since, when I modify the role of my user after my login page, this one is disconnectedBefore I did this in my...
View ArticleHow to get project directory from Symfony 4
What I need is the project directory or the public directory from symfony.use App\Kernel; class FileReader { public function __construct( Kernel $kernel ) { var_dump ($kernel->getProjectDir()); } }...
View ArticleTruncate string in Symfony Controller?
Is there a way to truncate a string directly in the controller?Something like:'description' => $result->getDescription()->truncate(80),
View ArticleSymfony 4 handling null DateType form field
I have a form in Symfony 4 where I implement the DateType as a text field->add('DateOfBirth', DateType::class, array( 'required' => false, 'widget' => 'single_text', 'empty_data' = )) however...
View ArticleNormalize virtual property with API Platform
I'm trying to return a virtual property with API Platform, but the only thing that I can get is the IRI.I have multiple User, linked to multiple Organization. Those Organization have only one "Owner"...
View ArticleCall to function getContainer on null in SonataAdmin
I'm trying to make some custom things over SonataAdmin in order to make it suit my needs.I have an abstract class extending the default AbstractAdmin from Sonata. In this abstract class there are other...
View Article