symfony4

How to hide or delete the defaults available console commands?

家住魔仙堡 提交于 2021-02-19 05:37:59
问题 I created a new Symfony 4 project via symfony new my_project_name . Currently when I execute ./bin/console , the output shows I will create some custom console commands and I want show only my custom commands when I do ./bin/console Maybe I should create a custom executable 'console' from scratch, but I don't know how do that. 回答1: You are creating a complete Symfony application, so all the commands provided by the included packages are available. Instead of starting from a framework and

Understanding @ParamConverter & @security annotations

三世轮回 提交于 2021-02-11 14:57:12
问题 I'm newing developing with symfony4. I'm trying to allow a user edit is own profile. I'm wondering about how can i allow a user to edit his "id" but not others id's from other users. This is my security.yaml access_control: - { path: ^/hardware, roles: ROLE_USER } - { path: ^/my, roles: ROLE_USER } - { path: ^/settings, roles: ROLE_ADMIN } And this is my specific controller for the action. As i read in order to do this action i must use at least the @security param and could be helpful the

How to add Login to swagger UI with API PLATFORM (symfony 4)?

风格不统一 提交于 2021-02-11 13:48:00
问题 I installed & configured LexikJWTAuthenticationBundle, it works fine but I've got a small problem. I have include the Authorization button for put the JWT token, the problem is the only way I can have my token is to use this commands: curl -X POST -H "Content-Type: application/json" http://localhost:8000/api/login_check -d '{"username":"johndoe","password":"test"}' It send my the token and I put it in the API, OK. First problem: When I try this request with POSTMAN I get an error : Unable to

Symfony messenger and mailer : how to add a binding_key?

╄→尐↘猪︶ㄣ 提交于 2021-02-10 20:21:54
问题 I have a running Symfony 4.4 project with messenger and rabbitMQ. I have an async transport with 2 queues. transports: # https://symfony.com/doc/current/messenger.html#transport-configuration async: dsn: '%env(MESSENGER_TRANSPORT_DSN)%' options: exchange: name: myexchange type: direct queues: email: binding_keys: - email extranet: binding_keys: - extranet # failed: 'doctrine://default?queue_name=failed' # sync: 'sync://' routing: # Route your messages to the transports 'App\Message

Why does autowiring provides a different entity manager instance for event subscribers?

早过忘川 提交于 2021-02-10 11:53:38
问题 I have different services in a symfony4 project, which get the entity manager injected. I found out, that doctrine event subscribers and services used by them get a different entity manager instance than the other services and when you call self::$container->get('doctrine')->getManager(). I have seen up to three different instances in my project, but I don't know under which circumstances even more instances are created. I have added the function spl_object_id to all constructors to see which

Why does autowiring provides a different entity manager instance for event subscribers?

本小妞迷上赌 提交于 2021-02-10 11:52:13
问题 I have different services in a symfony4 project, which get the entity manager injected. I found out, that doctrine event subscribers and services used by them get a different entity manager instance than the other services and when you call self::$container->get('doctrine')->getManager(). I have seen up to three different instances in my project, but I don't know under which circumstances even more instances are created. I have added the function spl_object_id to all constructors to see which

Why does autowiring provides a different entity manager instance for event subscribers?

那年仲夏 提交于 2021-02-10 11:51:21
问题 I have different services in a symfony4 project, which get the entity manager injected. I found out, that doctrine event subscribers and services used by them get a different entity manager instance than the other services and when you call self::$container->get('doctrine')->getManager(). I have seen up to three different instances in my project, but I don't know under which circumstances even more instances are created. I have added the function spl_object_id to all constructors to see which

Symfony 4 : “must implement interface DateTimeInterface” Error

巧了我就是萌 提交于 2021-02-08 11:33:27
问题 I'm creating an admin with easy admin bundle, i'm really new to Symfony4. I've a button "create a category" and when i click on it, I've this error : Return value of App\Entity\Category::getCreatedAt() must implement interface DateTimeInterface, null returned Code: <?php namespace App\Entity; use DateInterval; use DateTimeZone; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use DateTimeInterface; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity

How to do username case insensitive in login form?

本小妞迷上赌 提交于 2021-02-08 06:37:33
问题 I'm using the login form from Symfony, but I can't login, if the entered username is 'FOO' and in the DB is stored 'foo'. I'm using Postgres. It means the username-field is case sensitive. What can I do? 回答1: This depends mainly on your Database-Server. MySQL is case insensitive, PostgreSQL is case sensitive. But you can write query Like this $this->createQueryBuilder('user') ->where('LOWER(user.username) = :username') ->setParameter('username', strtolower($username)) ->getQuery() ->getResult

Use query_builder on CollectionType in symfony4 forms?

我怕爱的太早我们不能终老 提交于 2021-02-08 03:31:48
问题 In a symfony 4 form, I need to use something like a query_builder option that is available on EntityType but from a CollectionType . There is a similar question here with no good answers. In my project, each Site entity has many Goal . Each Goal has a numeric goal and a specific date. I'd like to edit the goals of a site for a specific date only. The problem is that a CollectionType form pulls all goals to show in the form, but I only want to pull the goals for a given date. How? There is no