草庐IT

symfony-http-foundation

全部标签

php - Symfony 2 kpn snappy 生成 pdf 输出符合安全区域

我正在使用Symfony2kpnsnappybundle生成pdf。我想用css从html页面生成PDF。我找到了一个解决方案,但它有一个问题:$pageUrl=$this->generateUrl('accounts_management_generate_pdf_markup',array('invoice'=>$invoiceData),true);//useabsolutepath!returnnew\Symfony\Component\HttpFoundation\Response($this->get('knp_snappy.pdf')->getOutput($pageUr

php - Symfony2 扩展 Controller getParameter()

我想将Symfony2Controller扩展到我使用API的项目,但我遇到了非对象使用getParameter()函数的错误,请查看我的代码:namespaceModa\CategoryBundle\Controller;useSymfony\Bundle\FrameworkBundle\Controller\Controller;classApiControllerextendsController{/***@varString*/protected$_host;/***@varString*/protected$_user;/***@varString*/protected$_p

php - $this->getRequest() 和在 Symfony 2 中将请求作为参数传递有什么区别

在ControllerAction中,我们可以通过两种方式获取请求对象:$request=$this->getRequest();或者将其作为参数传递给ActionpublicfunctiontestAction(Request$request)它们有什么区别?是获取请求的推荐方法还是特定情况下的首选方法? 最佳答案 实际上在Symfony2.4之前没有明显的区别。但是根据文档(https://github.com/symfony/symfony/blob/master/UPGRADE-3.0.md),您应该将请求对象作为操作方法参

php - 判断 HTTP 客户端是否断开连接

我有一个需要很长时间才能加载的php/apache页面。基本上,它看起来像这样:有时会发生客户端在处理过程中断开连接的情况,比方说,在step1和step2之间。php中有没有一种方法可以检查客户端是否仍处于连接状态,如果不是,则停止进一步处理?我希望我的代码是这样的:)die;doHeavyStuff_2();if()die;doHeavyStuff_3();if()die;printResults();?> 最佳答案 研究使用connection_aborted功能。 关于php-判

javascript - HTTP_X_REQUESTED_WITH 在 Firefox 4 中无法正常工作

我正在使用此代码重定向我的用户,从他们的浏览器中阻止仅使用ajax的页面if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])&&strtolower($_SERVER['HTTP_X_REQUESTED_WITH'])=='xmlhttprequest'){}else{header("Location:/");}它在Googlechrome、Firefox26和IE11上运行良好,但在firefox4中,即使在使用ajax加载时也会触发header。我该如何解决这个问题? 最佳答案 您可以尝试自己设

php - 我如何在 symfony Controller 中使用 Kint Debugger

我正在尝试使用它https://github.com/barelon/CgKintBundlehttps://github.com/raveren/kint调试现在我可以在TWIG模板中看到调试,但我不确定如何使用https://github.com/raveren/kint#installation-and-usage在symfonyphp类中。require'/kint/Kint.class.php';##########DUMPVARIABLE###########################Kint::dump($GLOBALS,$_SERVER);//anynumbero

php - Symfony2 : How to persist a new User in an admin-interface with FOSUserBundle?

我正在创建管理View,我可以在其中列出用户并创建用户。我已经创建了User类,但我不确定如何保留它。我是否需要手动创建表单然后保存它?我已经使用正常保存进行了保存,但随后执行了验证。我想知道我是否需要手动编码密码等,或者FOSUserBundle会为我做这些。 最佳答案 我假设您不打算使用...默认/registerroute/method对于新用户控制台command:app/consolefos:user:createtestusertest@example.comp@ssword...正如您所说的管理(网络)界面。回答:在C

php - Symfony 不能决定哪个类需要

这是我的错误:Theform'sviewdataisexpectedtobeaninstanceofclassMy\Bundle\Entity\Tags,butisaninstanceofclassDoctrine\Common\Collections\ArrayCollection.Youcanavoidthiserrorbysettingthe"data_class"optiontonullorbyaddingaviewtransformerthattransformsaninstanceofclassDoctrine\Common\Collections\ArrayCollect

php - 来自基本 Controller symfony2 的全局变量

我正在尝试拦截渲染函数或响应在加载View(Twig)之前向其添加变量。我试图覆盖默认的渲染方法,但它还是给我Variable"myvar"doesnotexistin/path/to/baseAppLite.html.twigatline10我的代码有什么问题,有没有更好的方法?这是我在baseController中的覆盖代码publicfunctionrender($view,array$parameters=array(),Response$response=null){$parameters=array_merge($parameters,array('myvar'=>'Glo

php - 路由路径中的 Symfony2 特殊字符

Symfony2默认按ID显示实体详细信息/***FindsanddisplaysaStateentity.*@Route("state/{id}",name="state_show")*@Template()*/我想显示州名,但大多数州都包含特殊字符(波兰语特殊字符)。如果我使用{name}链接有效,但在链接中使用特殊字符是否安全? 最佳答案 您可以使用Gedmoextensions为此,尤其是Sluggable. 关于php-路由路径中的Symfony2特殊字符,我们在StackOv