最近,我从symfony.com上的BETA版本开始了Symfony2的一个项目
过了一会儿,我需要升级到master分支,所以我从github中检索了最新的并在vendor/symfony中切换了它.
但是,我的bootstrap.php.cache和bootstrap_cache.php.cache未升级,这会产生错误.
我尝试清除symfony缓存,但无济于事.
如何更新这些文件以与我的项目相对应?
好的,所以我有一个index.php文件,它必须处理许多不同的文件类型.我怎么猜测基于的文件类型REQUEST_URI.
如果我请求http://site/image.jpg,并且所有请求都通过index.php重定向,这看起来像这样
<?php
include('/www/site'.$_SERVER['REQUEST_URI']);
?>
Run Code Online (Sandbox Code Playgroud)
我该如何正确地完成这项工作?
我应该根据所请求文件的扩展名进行测试,还是有办法获取文件类型?
在我的settings.yml文件中,我有几个配置变量,其中一些参考ENV []变量.
例如,我有ENV ['FOOVAR']等于WIDGET
我以为我可以在<%%>里面引用ENV变量,如下所示:
settings.yml中:
default:
cv1: Foo
cv2: <% ENV['FOOVAR'] %>
Run Code Online (Sandbox Code Playgroud)
在rails控制台中,如果我输入
> ENV['FOOVAR']
=> WIDGET
Run Code Online (Sandbox Code Playgroud)
但
> Settings.cv1
=> Foo (works okay)
> Settings.cv2
=>nil (doesn't work???)
Run Code Online (Sandbox Code Playgroud) 我编写了以下代码来从webservice获取JSON结果.
function SaveUploadedDataInDB(fileName) {
$.ajax({
type: "POST",
url: "SaveData.asmx/SaveFileData",
data: "{'FileName':'" + fileName + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
var result = jQuery.parseJSON(response.d);
//I would like to print KEY and VALUE here.. for example
console.log(key+ ':' + value)
//Addess : D-14 and so on..
}
});
}
Run Code Online (Sandbox Code Playgroud)
以下是来自webservice的回复:

请帮我打印Key和它的价值
是否有任何现有的降价规范,包括对RTL语言的支持?
我希望的是类似的东西
This paragraph is left to right
<- This paragraph is right to left
Run Code Online (Sandbox Code Playgroud)
或者某些东西......我可以调整我的解析器来处理这个但我想确保它已经不存在了.
我想改变php上传文件大小的限制
这是我的phpinfo的一些信息.
Configuration File (php.ini) Path /etc/php5/apache2
Loaded Configuration File /etc/php5/apache2/php.ini
Run Code Online (Sandbox Code Playgroud)
这是我的php.ini文件的内容:
upload_max_filesize = 50M
post_max_size = 50M
memory_limit = 128M
Run Code Online (Sandbox Code Playgroud)
然后我重启apache2,但phpinfo节目也是:
upload_max_filesize 2M
Run Code Online (Sandbox Code Playgroud) 我有一个例子,我试图使用Symfony2和FOSUserBundle创建一个AJAX登录.我设置我自己success_handler和failure_handler在form_login我的security.yml文件.
这是班级:
class AjaxAuthenticationListener implements AuthenticationSuccessHandlerInterface, AuthenticationFailureHandlerInterface
{
/**
* This is called when an interactive authentication attempt succeeds. This
* is called by authentication listeners inheriting from
* AbstractAuthenticationListener.
*
* @see \Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener
* @param Request $request
* @param TokenInterface $token
* @return Response the response to return
*/
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
if ($request->isXmlHttpRequest()) {
$result = array('success' => true);
$response = new Response(json_encode($result));
$response->headers->set('Content-Type', 'application/json');
return …Run Code Online (Sandbox Code Playgroud) 我正在为Symfony 2创建一个REST API控制器.我开始使用SensioGeneratorBundle创建一个CRUD并修改控制器以充当REST控制器.但是,我没有表格所以我正在考虑删除这部分.
如何在没有表格的情况下验证我的字段?一切都连接到表单,我想要一些自由,包括自定义字段名称.例如,POST x和y字段由Symfony解释为标题和内容.
我使用Symfony 2和Twig,我的问题很简单:
在视图中,我想基于变量扩展其中一个布局.如果变量是false我想要扩展UdoWebsiteBundle::layout.html.twig,如果true我想扩展UdoWebsiteBundle::layout_true.html.twig.
这是我试过的代码:
{% block layout_extender %}
{% if intro == 'false' %}
{% extends 'UdoWebsiteBundle::layout.html.twig' %}
{% else %}
{% extends 'UdoWebsiteBundle::layout_true.html.twig' %}
{% endif %}
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
第7行的"UdoWebsiteBundle:home:home.html.twig"中禁止使用多个扩展标记
有没有其他方法来实现这一目标?
我需要使用Symfony 2的缓存系统缓存一些特定于应用程序的数据,以便我可以运行cache:clear清除它.所有缓存都依赖于,app/cache但我如何实际缓存数据呢?
http://symfony.com/doc/current/cookbook/index.html
我看到的唯一主题是关于使用Varnish进行HTML缓存.