草庐IT

Symfony4

全部标签

php - Symfony 2 Embedded Forms: Catchable Fatal Error: Argument 1 passed to Entity::addProperty must be an instance of XX\MyClass, 数组给定

我已经读过this和this和其他人,但没有人解决我的问题。我已经删除了所有可能的内容并将范围缩小到一个字段:地址。当我尝试关注thistutorial时,如果我遵循它,一切都会正常,从一个全新的新项目开始。但是当我在我的其他项目中手动执行时,我得到了这个错误:“可捕获的fatalerror:传递给BN\Bundle\MyBundle\Entity\PersonTeacher::addAdresse()的参数1必须是BN\Bundle\MyBundle\Entity\Adresse的实例,C:\Users\Olivier\PhpstormProjects\中给出的数组My\My\src

php - symfony2 和 swiftmailer 的内存泄漏

我正在使用symfony2命令作为cron作业来向站点成员发送批量电子邮件。实际代码:$output->writeln('Before:'.(memory_get_usage()/1024/1024));$mailer->send($m);$output->writeln('After:'.(memory_get_usage()/1024/1024));我的结果:Before:182.38MBAfter:183.73MB每次我发送电子邮件时,swiftmailer都会额外消耗1+MB的内存。这似乎不对,但每次发送新消息时内存都会增加。我在这里做错了什么吗?

php - symfony2 中的自定义异常行为

我试图找出如何制作自定义异常行为。当我使用抛出异常时thrownew\Exception('Erroroccurredwithyourrequestpleasetryagain');我自动获得状态500和消息作为内部服务器错误但是我希望我的响应包含我的异常消息,而不仅仅是内部服务器错误,以便它显示如下内容:{"error":{"code":500,"message":"Erroroccurredwithyourrequestpleasetryagain"}}最重要的是可能会做一些额外的事情,例如通过电子邮件将错误发​​送给自己。但是,我只希望在抛出\Exception而不是使用类似的东

php - 在 Symfony2 中从 AuthenticationHandler 设置 flashMessage

我在使用FOSUserBundle时遇到问题,因为每当我使用错误的凭据登录时,我都会收到完整的堆栈跟踪信息作为错误消息:Error!exception'Symfony\Component\Security\Core\Exception\BadCredentialsException'withmessage'Badcredentials'in/var/www/html/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.p

php - 从 Controller Symfony2 中的 URL 获取参数

我尝试通过get方法提交我的表单,但是在Controller中我无法获取值,这里是Controller:var_dump($request->query->get('startPoint'));//itsNULL我的表格:{{form_widget(search_form,{'attr':{'class':'search_form'}})}}生成的网址:http://example.com/app_dev.php/search_trips?search_form%5BstartPoint%5D=3123123&search_form%5BendPoint%5D=&search_form

php - Symfony2 - 为服务指定的类型名称不匹配

我尝试使用我自己的ImageType配置EasyAdminBundle,以在我的ArticleType中上传文件。所以我在app\config\services.yml中创建了这个服务:services:oah_news_form_type_image:class:OAH\NewsBundle\Form\ImageTypetags:[{name:form.type,alias:'oah_news_form_type_image'}]并尝试在我的app\config\config.yml中调用它:easy_admin:entities:Article:class:OAH\NewsBund

php - Symfony 异常 : value required for $request argument

我有一个看起来像这样的loginAction:publicfunctionloginAction(Request$request){if($request->getMethod()=='POST'){$mail=$request->getContent('umail');$pass=$request->getContent('upass');$em=$this->getDoctrine()->getManager();$rep=$em->getRepository('SystemBundle:User');$user=$rep->findOneBy(array("email"=>$ma

php - 如何在 Symfony 2.7 中关闭用户的所有 session ?

用户更改密码后(在恢复密码操作中),我需要使所有连接到该用户的session无效(他可能登录了多个浏览器/设备)。因此,在我将使用新密码的用户保存在数据库中之后,我需要关闭该用户在不同浏览器/设备中可能处于事件状态的所有session。我试过这个:$token=newUsernamePasswordToken($user,null,'main',$user->getRoles());$this->get('security.token_storage')->setToken($token);还试过:$this->get('security.token_storage')->getTok

php - Doctrine - Symfony 查询错误

我确实有一个错误,但我不知道如何修复它。$query=$entityManager->createQuery("UPDATEAppBundle:ChangeAPISET`key`='asd123'WHERE`id`=1");$query->execute();我的AppBundle:ChangeAPI/***@ORM\Entity*@ORM\Table(name="api")*/classChangeAPI{/***@ORM\Column(type="integer")*@ORM\Id*@ORM\GeneratedValue(strategy="AUTO")*/protected$id

php - Symfony 4 中的注解

我尝试使用Symfony4进行开发,所以我遵循symfony.com上的教程当我尝试访问:时出现错误http://localhost:8000/这是错误:[SyntaxError]ExpectedPlainValue,got'''atposition7inmethodApp\Controller\HomeController::home()in/Users//Documents/ProjetSymfo4/my-project/config/routes/../../src/Controller/(whichisbeingimportedfrom"/Users//Documents/Pr