Tag: symfony

为什么Symfony2在基准testing中performance如此糟糕,这有什么关系?

我和我的同事正在select一个Web框架来开发一个高stream量的网站。 我们真的很擅长node.js + express和php + symfony2 。 两者都是很好的框架,但是我们对Symfony2有点担心,因为它似乎超过了大多数Web框架。 以下是certificate它的基准: http : //www.techempower.com/benchmarks/ 由于这个原因,我们可能会使用node.js + express,但是我仍然想知道为什么Symfony2在基准testing中performance如此糟糕。

从root用户运行凉亭,有可能吗? 怎么样?

我有一个本地开发服务器,在这里我testing了很多东西,现在我正在玩鲍尔来pipe理我的Symfony2项目中的库依赖项。 在安装NodeJS(v0.10.31)和bower(1.3.9)之后,我尝试以root身份从控制台运行命令sp:bower:install ,它属于Symfony2 SpBowerBundle: Symfony > sp:bower:install Installing bower dependencies for "TemplateBundle" into "/var/www/html/tanane/src/Tanane/TemplateBundle/Resources/config/bower/../../public/components" bower ESUDO Cannot be run with sudo Additional error details: Since bower is a user command, there is no need to execute it with superuser permissions. If you're having permission errors when using bower without sudo, please spend a few minutes […]

使用FOSUserBundle创build新用户失败

我试图从命令行创build一个新的用户,并得到这个错误: Warning: array_search() expects parameter 2 to be array, null given in /vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Model/User.php line 368 当试图通过在web界面注册创build一个用户时,我得到这个: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'salt' cannot be null 使用已经存在的用户login即可。 还更新configuration文件并更改密码。 只是创build新用户不起作用。 我在一个非常简单的设置中使用v 1.3.1,还没有find任何解决scheme。 有任何想法吗?

Symfony2禁用caching?

有没有办法在Symfony2中禁用cachingfunction? 我试图findconfig *和parameters.ini文件中的设置,我search了很多。 好的,我find了一些解决scheme,但没有为最新版本(Symfony2)。 为什么? 因为我想要testing新的模板和函数,而不必一直清除应用程序/caching*。

如何以编程方式login/authentication用户?

我想在注册过程之后立即login用户,而不通过login表单。 这可能吗 ? 我已经find了FOSUserBundle的解决scheme,但是我并没有将它用于实际工作的项目。 这里是我的security.yml,我正在使用两个防火墙。 纯文本编码器仅用于testing。 security: encoders: Symfony\Component\Security\Core\User\User: plaintext Ray\CentralBundle\Entity\Client: md5 role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] providers: in_memory: users: admin: { password: admin, roles: [ 'ROLE_ADMIN' ] } entity: entity: { class: Ray\CentralBundle\Entity\Client, property: email } firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false user_login: pattern: ^/user/login$ anonymous: ~ admin_login: pattern: ^/admin/login$ anonymous: ~ […]

如何在symfony2全局帮助函数(服务)中访问服务容器?

这个问题始于我不明白为什么我不能将variables传递给symfony2全局帮助函数(service),但是由于比我更亮的人,我意识到我的错误是关于尝试从类中使用security_context没有注入所以… 这是最后的结果,代码是有效的。 我发现没有更好的方法使这对社区有帮助。 这是如何从symfony2中的全局函数或帮助函数中获取来自security_context的用户和其他数据。 我有以下类和function: <?php namespace BizTV\CommonBundle\Helper; use Symfony\Component\DependencyInjection\ContainerInterface as Container; class globalHelper { private $container; public function __construct(Container $container) { $this->container = $container; } //This is a helper function that checks the permission on a single container public function hasAccess($container) { $user = $this->container->get('security.context')->getToken()->getUser(); //do my stuff } } …定义为一个服务(在app / config / […]

EntityManagerclosures

[Doctrine\ORM\ORMException] The EntityManager is closed. 插入数据后,我得到一个DBALexception后,EntityManagerclosures,我无法重新连接。 我试过这样但是没有得到连接。 $this->em->close(); $this->set('doctrine.orm.entity_manager', null); $this->set('doctrine.orm.default_entity_manager', null); $this->get('doctrine')->resetEntityManager(); $this->em = $this->get('doctrine')->getEntityManager(); 任何人有一个想法如何重新连接?

如何将@request注入到服务中?

当我尝试将@request注入到我的任何服务中时,出现以下exception: ScopeWideningInjectionException:范围扩展注入检测:定义“service.navigation”引用属于较窄范围的服务“请求”。 通常,将“service.navigation”移动到范围“request”或者通过注入容器本身来依赖提供者模式并且在每次需要时请求服务“请求”是更安全的。 在罕见的特殊情况下,可能不需要,那么你可以将参考设置为strict = false来摆脱这个错误。 什么是最好的方式进行? 我应该尝试设置这strict=false和如何,或者我应该不注入请求服务,而是通过我的控制器每次我调用我需要的函数传递给服务? 其他的可能性是注入内核并从中取出,但是在我的服务中,我只使用@router和@request,因此注入整个内核将是不合理的。 谢谢!

如何自定义Symfony 2表单中的data-prototype属性

因为在几天的时间里,我阻止了Symfony 2和表格的问题。 我有一个网站实体的forms。 “网站”是网站实体的集合,每个网站包含两个属性:“types”和“url”。 如果我想在我的数据库中添加更多的网站,我可以点击一个“添加另一个网站”链接,在我的表单中添加另一个网站。 所以当你点击提交button时,你可以同时添加一个或X个网站。 这个过程添加一行使用data-prototype属性,它可以生成网站的子表单。 问题是,我自定义我的窗体有一个伟大的graphics渲染…像这样: <div class="informations_widget">{{ form_widget(website.type.code) }}</div> <div class="informations_error">{{ form_errors(website.type) }}</div> <div class="informations_widget">{{ form_widget(website.url) }}</div> <div class="informations_error">{{ form_errors(website.url) }}</div> 但数据原型不关心这个定制,与HTML和CSS标签和属性。 我保持Symfony渲染: <div> <label class=" required">$$name$$</label> <div id="jobcast_profilebundle_websitestype_websites_$$name$$"> <div> <label class=" required">Type</label> <div id="jobcast_profilebundle_websitestype_websites_$$name$$_type"> <div> <label for="jobcast_profilebundle_websitestype_websites_$$name$$_type_code" class=" required">label</label> <select id="jobcast_profilebundle_websitestype_websites_$$name$$_type_code" name="jobcast_profilebundle_websitestype[websites][$$name$$][type][code]" required="required"> <option value="WEB-OTHER">Autre</option> <option value="WEB-RSS">Flux RSS</option> … </select> </div> […]

如何使用JMSSerializerBundle创build一个好的超媒体格式?

比方说,我想创build一个XML-响应,将如下所示: <?xml version="1.0" encoding="utf‐8"?> <product xmlns="urn:com.acme.prods" xmlns:atom="http://www.w3.org/2005/xlink"> <id>1234</id> <name>Red Stapler</name> <price currency="EUR">3.14</price> <atom:link rel="payment" type="application/com.acme.shop+xml" href="http://acme.com/products/1234/payment" /> </product> 给定一个类似于下面的域模型: <?php // Product.php namespace Acme\Bundle\ProductBundle\Entity; use Acme\Bundle\ProductBundle\Money\Money; class Product { /** * @var integer */ private $id; /** * @var string */ private $name; /** * @var Money */ private $price; [..] } 和一个货币类别的线: <?php // […]