问题标签 [symfony-2.8]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
php - 如何在控制器文件夹之外调用函数且没有路由?
我在命名空间下StringTools
定义了以下类Clanmovil\PlatformBundle\Tools
:
现在我想使用该函数的输出,让我们通过 AJAX 进行调用,正确的方法是什么:
- 创建一个控制器并在里面创建一个实例化该函数的
permutationWords()
函数,然后通过路由调用控制器函数? - 有没有其他更好更干净的方法来实现这一点,我不知道?
symfony - Translator::getMessages 返回一个空数组
我正在尝试translator.default
在 a 中使用该服务Controller
,但是我尝试通过该trans
方法翻译的任何消息都会返回未翻译的密钥。
为了确保我的密钥被正确加载,我做了以下检查:
输出以下内容:
我的密钥存储在<root>/app/resources/translations/messages.it.yml
我的语言环境下,当请求翻译的密钥设置良好时:
如果在我的控制器中调用,这会生成以下输出:"it",我猜它是正确的。所以:我哪里错了?
编辑
这是我的<root>/app/Resources/translations/messages.it.yml
这是与我的翻译服务相关的块<root>/app/config/config.yml
我正在使用开发配置,但与那里的翻译无关。
php - Symfony 2.8 的 LDAP 身份验证
我正在尝试在 Symfony 2.8 中使用新的 LdapUserProvider。我相信我已经按照文档配置了所有内容。
我的用户可以成功进行身份验证,然后被重定向到安全页面。重定向之后是问题开始的地方。Symfony 尝试以经过身份验证的用户身份绑定,但密码为空,被 open ldap 拒绝。
以下是相关的日志条目和配置值。
配置:
安全:
和日志文件:
unit-testing - 只有在 Symfony 2.8 中进行单元测试时,服务类中的 Twig_Environment 才会导致 DIC RuntimeExtension
我使用 Twig_Environment 呈现要发送的 html 邮件。我有一个 NotificationService 类,其他服务使用它来发送这些邮件。
在正常使用中,一切正常,但由于更新到 2.8,单元测试失败:
Symfony\Component\DependencyInjection\Exception\RuntimeException: You have requested a synthetic service ("kernel"). The DIC does not know how to construct this service
我调试了 StackTrace,问题似乎是 Twig_Environment (它使用 which file_locator
injections kernel
)
关于如何解决这个问题的任何指示?
编辑:(根据要求)
编辑2:
EDIT3:获取内核似乎在过去有时发生了变化。见http://symfony.com/doc/master/cookbook/testing/doctrine.html
我改变了我的构造函数:
到:
但不幸的是,当测试使用 Twig_Env 时,它不能修复 RuntimeException。
doctrine-query - DQL 子查询 - 已定义
我正在尝试在第 5 个 DQL 子查询中重用定义名称“comments”-表 Comments (AppBundle:Comments entity),但出现错误:"Error: 'comments' is already defined."
这是 DQL 查询:
如何在不重新定义的情况下重用定义?
我也试过这个:
,但现在我得到“未定义类'评论'。” 错误。
php - Symfony 使用 mod_rewrite 导致重定向错误
我在 CentOS 7 虚拟机上运行了 symfony 2.8。现在,当我尝试访问我的站点时,出现内部服务器错误。当我检查日志时,它说:
我将LogLevel
in apache 设置为 trace3,看起来 app.php 周围有一大堆重定向。我不确定发生了什么。我没有修改 symfony 附带的 .htaccess 文件。这是我的 .htaccess 文件中的 mod_rewrite 块:
这是我的 httpd.conf (不要担心任何安全问题。这只是用于开发目的的本地安装)
我看不到这个重定向一直在哪里发生。我错过了什么?
php - Unable to setup Symfony2 framework with NetBeans IDE (8.1)
Stuck at Error: "Symfony console must be selected"
I've been trying for almost a week to set up an environment to develope a web application using Symfony2 framework and NetBeans IDE. I already have a an HTML-Bootstrap-Javascript project ready. There is no engine to the car yet, except for a few trial use cases. The requirement is to select an approriate framework and IDE to develop the php part of the application.
I've done the following:
- Installed the installer from command line and moved to the projects folder (which is in the wamp/www directory)
- Created new symfony project from command line ( php symfony new Test)
- Downloaded and installed NetBeans 8.1 (I've tried 8.0.1 as well, thinking that using the .zip file from GitHub might solve the problem as most solutions online to similar issues are related to using the .zip folde - 8.1 takes installer path)
- In NetBeans tools/options I've given path to php.exe and under frameworks "Installer" selected the installer file I had downloaded (D:\wamp\www\projects\symfony). One thing that bugs me here is that if I click "Search.." after selecting this path, it doesnt find the installer.
After creating new project, and going through all the steps of the wizard (selecting framework symphony2) I get the error "symfony2 console must be selected" At this point the options dialog box comes to foreground with the "frameworks & tools" tab open.Option dialog box when pops up when error dialog box is closed
Since I'm not using any zip file, instead I'm using the installer, I cannot apply the recommendations on another post here which talks about extracting the zip folder and creating a new zip folder with the sub contents.
Getting frustrated with this combo now, btw...I have tried an older version of NetBeans so I could use the .zip folder from GitHub, implemented the solution I found on stackoverflow....same result. I can really use some help here!! Thanks in advance.
php - Symfony2 - use of Delete form in CRUD operation
the adutomatic crud operation generated by symfony and also the symfony demo application has the following code structure for the delete action
my question is why do we need a form to delete? cant we just have a link in the twig with an id
parameter set accordingly, cant we just do the following, why do we need to check if the entity isValid()
inside a form before deleteing it?
php - 如何在 symfony2 中从多方面创建嵌入表单
我有一个像这样的体育锦标赛数据库架构
这里doman
有one to many
关系tournament
,我有一个domain
收集域详细信息并将其存储在数据库中的表单,我有这样的锦标赛和域表
我有一个tournamentType
收集锦标赛详细信息的文件,但提交后显然会有一个null
值domain_id
。我如何为tournaments
将要创建的所有内容设置域值让我们说domain_id = 1
。
我可以使用 setter 在控制器中执行此操作,但这会很麻烦,有没有办法在 symfony 嵌入式表单中one
从侧面设置侧面,many
编辑:现在我正在这样做,在控制器内部
在锦标赛实体的二传手内部
每件事都很好,我只是不想使用控制器内的设置器,我想将它移动到其他地方