草庐IT

symfony-plugins

全部标签

php - Symfony 2.7 : default timezone not set, 导致 fatal error

我正在尝试在共享服务器上设置一个基于symfony2.7的应用程序,并且没有权限更改php.ini.执行:phpapp/consoledoctrine:schema:drop--force输出此警告/错误:PHPWarning:Uncaughtexception'Symfony\Component\Debug\Exception\ContextErrorException'withmessage'Warning:date_default_timezone_get():Itisnotsafetorelyonthesystem'stimezonesettings.Youare*requir

php - 从 Symfony/Twig 中的覆盖版本访问父模板

我有一个第三方包OriginalBundle,我想自定义其中的一些模板。为此,我使用theoverridemethodshownintheSymfonydocs设置了一个Symfony包MyCustomBundle.然后我使用MyCustomBundle从OriginalBundle创建一些Twig模板的覆盖版本。但是,我希望能够从我的版本访问原始模板(例如扩展它)并覆盖一些block。但是,如果我尝试做这样的事情:{#MyCustomBundle:Foo:bar.html.twig#}{%extends'OriginalBundle:Foo:bar.html.twig'%}{%blo

php - WordPress 错误 : Call to undefined function in plugin

我一直在使用ShortcodeExecPHP插件编写一个函数,当我在编辑器中运行该函数时效果很好。当我将它移动到插件时,我开始在日志中看到如下错误:PHPFatalerror:Calltoundefinedfunctionwp_create_category()我意识到这是因为缺少包含等。为插件包含内置wordpress功能的正确方法是什么?我的插件使用了以下wordpress函数wp_create_categoryusername_existswp_generate_passwordwp_create_userwp_insert_postupdate_post_metaadd_pos

php - 如何保护 symfony2 中除登录页面之外的整个页面?

我想通过使用FOSUserBundle登录来确保整个站点的安全。我试过这样设置security.ymlsecurity:encoders:Symfony\Component\Security\Core\User\User:plaintextFOS\UserBundle\Model\UserInterface:sha512role_hierarchy:ROLE_ADMIN:ROLE_USERROLE_SUPER_ADMIN:[ROLE_USER,ROLE_ADMIN,ROLE_ALLOWED_TO_SWITCH]providers:fos_userbundle:id:fos_user.u

php - Symfony2 表单集合 : How to remove entity from a collection?

我尝试从集合中删除实体,但它不起作用。我想我在某处有错误,但我不知道在哪里。这是我的updateAction中的代码:$em=$this->getDoctrine()->getEntityManager();$entity=newPerson();if(!$entity){throw$this->createNotFoundException('UnabletofindPersonentity.');}$editForm=$this->createForm(newPersonType(),$entity);$deleteForm=$this->createDeleteForm($id)

php - 如何在 Symfony2 中捕获 ParamConverter 异常?

这是我遇到的异常:Noresultwasfoundforqueryalthoughatleastonerowwasexpected.当在数据库中找不到用户ID时,我基本上会遇到该异常。这是我的路线:localhost/../user/18以及我Controller中的代码:publicfunctionshowAction(User$user){//..}我知道我可以使用内核事件异常来处理这个问题,但是有没有更简单的方法来捕获由ParamConverter生成的异常? 最佳答案 在某些情况下,如果找不到对象,手动抛出异常是很有用的。如

php - Symfony2 - 生成 :bundle is not defined

我想生成一个新包,但它说命令generate:bundle未定义。当我尝试这个命令时:phpapp/consolelist--raw生成:未显示捆绑...命令输出:helpDisplayshelpforacommandlistListscommandsassetic:dumpDumpsallassetstothefilesystemassets:installInstallsbundleswebassetsunderapublicwebdirectorycache:clearClearsthecachecache:warmupWarmsupanemptycacheconfig:dump

php - Symfony 2.5 "You have requested a non-existent service "siteTest.b"

当运行workspace/app_dev.php时,没问题。但是当我尝试运行workspace/app.php时,我得到:"Youhaverequestedanon-existentservice"siteTest.b"我不知道我做错了什么。应用程序/配置/config.yml:imports:-{resource:parameters.yml}-{resource:security.yml}framework:secret:"%secret%"router:resource:"%kernel.root_dir%/config/routing.yml"strict_requiremen

php - Symfony 3 将所有路由重定向到当前语言环境版本

我正在开发一个symfony应用程序,我的目标是无论用户在哪个页面上,它都会导航到该页面的语言环境版本。例如,如果用户导航到“/”主页,它将重定向到“/en/”如果他们在“/admin”页面上,它将重定向到“/en/admin”,以这种方式从路由设置_locale属性.如果他们从用户浏览器访问/admin,它还需要确定语言环境,因为没有确定语言环境,所以它知道要重定向到哪个页面。目前我的默认Controller如下所示,因为我正在测试。我正在使用开发模式和分析器来测试翻译工作是否正确。get('translator')->trans('Symfonyisgreat');//replac

php - 在 Symfony2 中使用动态放置的 HTML 渲染 Twig 模板?

我有一个Action和一个Twig模板。通过render()可以为Twig-tag{{tagname}}放置文本。但是这个文本被转义了。现在我想放置(未转义的)HTML代码。在Symfony2中是如何完成的? 最佳答案 转义由Twig处理。{{var}}导致转义输出。{{var|raw}}导致原始/未转义输出。rawisafilter. 关于php-在Symfony2中使用动态放置的HTML渲染Twig模板?,我们在StackOverflow上找到一个类似的问题: