symfony-3.3

getLastUsername from AuthenticationUtils always empty

送分小仙女□ 提交于 2021-01-28 10:41:03
问题 So my code is pretty straightforward, I have a login form, an authenticator, and a login method in the controller. In my authenticator class, when user credentials are wrong, I store the email used in the session. See below ( specifically the getCredentials method ) : <?php namespace AppBundle\Security; use Psr\Log\LoggerInterface; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony

Symfony Doctrine update query fail

浪尽此生 提交于 2021-01-28 05:33:35
问题 My code is: $query = $em->createQuery("UPDATE AppBundle:Project u SET u.name=1, u.key=?2, u.leader=?3 WHERE u.id = ?4"); $query->setParameter(1, $project->name); $query->setParameter(2, $project->key); $query->setParameter(3, $project->lead->name); $query->setParameter(4, $project->id); $result = $query->getResult(); Now when I run it, it gives me a error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your

$this->container is NULL in Controller on Symfony3

早过忘川 提交于 2021-01-27 18:47:28
问题 I got an annoying problem when I call this in a controller (ClientDomainController) : $this->getDoctrine()->getManager(); I got this error : Call to a member function has() on null I looked the stack trace and see that : $this->container is null My controller extends from the Symfony Controller component : use Symfony\Bundle\FrameworkBundle\Controller\Controller; The funny thing is that in an other controller (HomeController) I make the exact same things : Extend from Controller (the exact

VichUploaderBundle - namer: Parent definition does not exist

不羁的心 提交于 2021-01-27 04:42:18
问题 config.yml vich_uploader: db_driver: orm mappings: media_image: uri_prefix: '%uploads_dir%' upload_destination: '%kernel.root_dir%/../web/uploads/images' namer: Vich\UploaderBundle\Naming\OrignameNamer Entity: /** * Media * @Vich\Uploadable * @ORM\Table(name="medias") * @ORM\Entity(repositoryClass="AppBundle\Repository\MediaRepository") */ class Media { use TimestampableEntity; /** * @var int * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */

Symfony 3.3 services autoconfiguration

限于喜欢 提交于 2020-01-22 20:08:02
问题 I'm trying migrate to symfony 3.3 and use new feature autowire / autoconfigure services: So in services.yml i have: services: _defaults: autowire: true autoconfigure: true public: false # makes classes in src/AppBundle available to be used as services AppBundle\: resource: '../../src/AppBundle/*' # you can exclude directories or files # but if a service is unused, it's removed anyway exclude: '../../src/AppBundle/{Entity,Controller,DQL,Form/DataTransformer,Repository}' i declare my twig

Connection to a db with Doctrine pdo_sqlsrv

余生长醉 提交于 2020-01-14 03:37:07
问题 I'm trying to connect to my database in SQL Server 2000, but i get an error could not find driver when i'm using pdo_sqlsrv. But if i use sqlsrv i get an error Attempted to call function "sqlsrv_configure" from namespace "Doctrine\DBAL\Driver\SQLSrv". Here is my config.yml config.yml doctrine: dbal: default_connection: default connections: default: dbname: "%database_name%" user: "%database_user%" password: "%database_password%" host: "%database_host%" driver: pdo_mysql charset: utf8mb4

How to avoid “knp_menu.factory” deprecation?

狂风中的少年 提交于 2020-01-07 04:41:08
问题 I'm trying to use KNPMenuBundle with Sumfony 3.3 but I'm getting this annoying warning: Autowiring services based on the types they implement is deprecated since Symfony 3.3 and won't be supported in version 4.0. You should rename (or alias) the "knp_menu.factory" service to "Knp\Menu\FactoryInterface" instead. Trace: {..../vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php:344: } I did not set this knp_menu.factory at all, probably it was automatically

Load different Data Fixtures depending on configuration in Symfony 3

断了今生、忘了曾经 提交于 2019-12-25 09:28:01
问题 At the moment we are developing a pack of microservices for a few online-shops (and possible future new ones). For business reasons we will have different implementations of the same software, so each shop will ask to its one. I need to set a different pack of initial data on the database depending on the implementation, which means different Data Fixtures for each one. I'm looking for a good way to load the proper fixtures depending on configuration parameters (company_name, company_slug...)

DoctrineCacheBundle: I cannot undersatand the documentation for using it with redis

☆樱花仙子☆ 提交于 2019-12-25 00:17:56
问题 As I was looking the documentation in order to figure out how to use it in order to Cache APi results. I cannot understand how to setup the configuration in order to make it work with either redis or predis. I tried the following con figuration: doctrine_cache: aliases: my_cache: 'redis' providers: redis: host: '%redis_host%' port: '%redis_port%' aliases: - my_cache But as I was tryint to debug my container with: php bin/console debug:container doctrine I got the error: "host" is an

Many to many doesn't persist

不想你离开。 提交于 2019-12-24 20:07:07
问题 I'm developing a website with the PHP framework Symfony 3.3 and the ORM Doctrine. I have users, and each user can offer services. A service can be offers by more than one user. Everything is working well, except when I want to persist a services list of a user. Nothing happens and I don't get any error. Can you see anything that is wrong in my code? My MySQL user table: CREATE TABLE `user` ( `id_user` INT(11) NOT NULL AUTO_INCREMENT, `firstname` VARCHAR(255) NOT NULL, `surname` VARCHAR(255)