草庐IT

Symfony3

全部标签

php - Symfony 2.8 - 如何为任何 URL 配置防火墙?

每当我故意-尝试自定义错误页面-尝试访问未定义的路由时,服务器都会响应500错误。日志说:request.CRITICAL:Exceptionthrownwhenhandlinganexception(Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException:Thetokenstoragecontainsnoauthenticationtoken.OnepossiblereasonmaybethatthereisnofirewallconfiguredforthisURL.此

php - 如何在 Symfony2 的单独表中存储用户角色?

我的Symfony2.8项目中有以下原则实体。用户idemailusernamepassword组织idnamesubdomain用户组织organization_iduser_idroles我需要从UserOrganization表加载用户角色,那么我如何覆盖Symfony身份验证流程以从“UserOrganization”实体加载用户角色。注意:xyz.mydomain.com这里的xyz是组织。因此,当用户尝试从xyz子域登录时,Symfony2必须从UserOrganization表中的xyz组织记录中读取用户的角色 最佳答案

php - symfony/FOSRestBundle : empty JSON response (using the symfony embodied serializer)

我正在学习使用symfony构建API(使用FOSRestBundle)。我正在学习法语教程。显然,我首先尝试自己编写代码,但即使使用复制/粘贴,当我向适当的路由(rest-api.local/places)发出GET请求时,它仍然让我得到空的JSON数组。如果我在php数组中“格式化”代码,代码工作正常:publicfunctiongetPlacesAction(Request$request){$places=$this->get('doctrine.orm.entity_manager')->getRepository('AppBundle:Place')->findAll();

php - Symfony 控制台 - 创建文件?

Symfony的新手,使用命令行界面:Usage:command[options][arguments]Options:--help(-h)Displaythishelpmessage--quiet(-q)Donotoutputanymessageetc...我想知道是否有任何方法可以直接从这个界面创建文件?所以在Symfony控制台中类似于"echo'ThisWorked'>test.php"的东西,允许我将代码测试推送到我服务器上的新文件或现有文件。我已经可以使用doctrine:query:sql写入SQL,想知道是否有用于写入本地文件的东西? 最佳答

php - Symfony @ParamConverter : exclude the use if the placeholder does not contain a dot

我有这个Controller:/***{@inheritdoc}**@Route("entity/{domain_host}")*@ParamConverter("entity",class="AppBundle:Entity",options={*"repository_method"="findOneByDomainHost",*"mapping":{"domain_host":"domainHost"},*"map_method_signature"=true*})*/classEntityControllerextendsController{...}通过这种方式,像http:

php - Symfony:如何使 JMS 序列化程序与严格类型一起工作?

这是我的情况:我正在尝试编写一个适用于“严格”类型(整数、bool值和float)的SymfonyRESTAPI,因为默认的Symfony行为不支持它并且我想避免强制转换类型(例如:JMSSerializerconvertsstringvalueintointegerfieldtype)为此,我创建了一个自定义处理程序,它实现了JMS\Serializer\Handler\SubscribingHandlerInterface(例如StrictIntegerHandler):GraphNavigator::DIRECTION_DESERIALIZATION,'format'=>'jso

php - Symfony 3.2 FOSUserBundle Ajax 登录

在FOSUserBundle中,我想在用户登录后将用户重定向到fos_user_profile_show路由而不加载页面(AJAX查询)。我卡在了这一点上。论坛里有类似的话题,但是已经过时了。AuthenticationHandler.phprouter=$router;$this->session=$session;}/***@paramRequest$request*@paramTokenInterface$token*@returnJsonResponse|RedirectResponse*/publicfunctiononAuthenticationSuccess(Reques

javascript - Symfony 3 - CSRF token 仅在使用 AJAX 提交时无效

环顾四周,我找不到解决这个问题的方法。只有在通过Ajax提交时,我才会收到以下错误。这意味着我事先已经以常规的Symfony方式提交了表单,没有任何问题。TheCSRFtokenisinvalid.Pleasetrytoresubmittheform.什么有效:常规表单提交,即不使用Ajax我使用Ajax检查$_POST是否正确填充,包括CSFRtoken,就在Controller端提交之前,如下所示:$form->submit($request->request->get($form->getName('user')));根据要求,查看下面的输出var_dump($request->

php - Symfony 3.3.3 - 默认 Controller 和容器

我下载了Symfony(3.3.3)的最新稳定版本,但在启动时出现错误:Attemptedtocallanundefinedmethodnamed"getParameter"ofclass"AppBundle\Controller\DefaultController".这是:'base_dir'=>realpath($this->getParameter('kernel.project_dir')).DIRECTORY_SEPARATOR,3.3.3版本之前的SymfonyController扩展Symfony\Bundle\FrameworkBundle\Controller\Con

php - symfony 3 的缓存失效是如何工作的?

你好我想集成symfony的缓存失效但是这个并没有删除缓存我用的是memcached在存储库中我添加了标签$query=$this->getEntityManager()->createQuery($sql)->setParameters($params); $cacheData=$cache->getItem(md5(serialize($query->getParameters())).$page);  if(!$cacheData->isHit()){$result=$query->setFirstResult(($page-1)*$maxPerPage)->setMaxResu