我在Cloudcontrol上设置Symfony 2有点问题,
我按照说明安装了Symfony 2框架,更改了文档根目录等等.
现在,当我尝试将更改推送到服务器服务器时,它会从composer.json加载依赖项,然后失败并显示一条消息:
[RuntimeException]
无法扫描"/ srv/tmp/builddir/code/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Resources/stubs"中的类,这些类似乎不是文件,也不是文件夹
此文件是从composer加载的供应商包.
我对示例项目(SF2)中的默认composer.json文件有同样的效果
Localy它运作得很好!
有人可以给我一个暗示吗?
浏览器模式时如何删除"清除字段"X按钮:IE9文档模式:某些输入上的IE9.
我用这个代码
<STYLE type="text/css">
input[type=text]::-ms-clear{
display: none;
}
input[type=password]::-ms-reveal{
display: none;
}
</STYLE>
Run Code Online (Sandbox Code Playgroud)
当我选择浏览器模式如浏览器模式时,它工作正常:IE9和文档模式:标准和(IE8,IE7)相同.但是当我选择浏览器模式浏览器模式时,它不起作用:IE9和文档模式:IE9和与(IE8,IE7)相同.
我有一个在Symfony2中创建的网站,现在我想要在移动应用程序中提供该网站的许多功能.
我的想法是通过附加一个简单的URL变量,然后它将在JSON中输出相关页面请求的所有变量.
所以,如果我连接到
www.domain.com/profile/john-smith
Run Code Online (Sandbox Code Playgroud)
它现在返回HTML页面.
但是,如果我去
www.domain.com/profile/john-smith?app
Run Code Online (Sandbox Code Playgroud)
然后它返回一个名称,年龄和其他配置文件信息的JSON对象.
我的应用程序代码然后接收JSON和进程.
我看不到任何安全问题,因为它实际上是JSON中提供的变量而没有HTML.
通过执行上述操作,我可以创建所有应用程序代码,只需调用与网页相同的URL,这将返回JSON中的变量,并节省了对更多服务器端工作的需求.
问题是:如果不修改每个控制器,我该怎么做?
我无法想象一个事件监听器会这样做吗?也许我可以拦截Response对象并删除所有HTML?
有关最佳实践方法的任何想法吗?它应该很容易编码,但我正试图弄清楚它的设计.
我dirname(__FILE__)在php脚本中使用包含但是前几天我将它作为字符串的一部分包含在内并且它导致了错误.有任何想法吗?
这条线是
private $errorfile = dirname(__FILE__).'/../../../error_logs/error.log';
Run Code Online (Sandbox Code Playgroud)
要么
private $errorfile = '/../../../error_logs/error.log';
error_log($message,3, dirname(__FILE__).$this->errorfile);
Run Code Online (Sandbox Code Playgroud)
它导致了一个错误,如
PHP解析错误:语法错误,意外'(',期待','或';'在/home2/futsalti/public_html/_futsal-time-v4.9/public/scripts/php/databaseClass.php
PHP Parse错误:语法错误,意外';' 在/home2/futsalti/public_html/_futsal-time-v4.9/public/scripts/php/databaseClass.php
编辑:
好吧,刚来找我......也许问题应该是我可以dirname(__FILE__)在课堂上使用吗?
我正在构建一个silex应用程序(源代码在这里)
在App\Form\DataTransformer我有一个MetadataTransformer类.
但该transform方法不起作用(反向转换).
它适用于a App\Form\Metadata AbstractType,它是一个集合的一部分App\Form\ArticleForm AbstractType.
最后一个表单是在我的编辑方法中调用的App\Controller\Admin\ArticleAdminController
数据转换器应该映射这样的数据
{"key":"value"}
Run Code Online (Sandbox Code Playgroud)
进入"表格数据",如:
[{"name":"key","value":"key"}]
Run Code Online (Sandbox Code Playgroud)
因此它可以显示为集合.
Metadata.php
class MetaData extends AbstractType
{
protected $span4 = "span4";
protected $span3 = "span3";
public function buildForm(FormBuilderInterface $builder,array $options)
{
$builder
->add('name', 'text', array(
"label" => ' ',
"attr" => array(
"class" => $this->span3,
"placeholder" => "name"
)
))
->add('value', 'text', array(
'label' => ' ',
'attr' => array(
"class" => $this->span4,
'placeholder' => 'value'
)
)) …Run Code Online (Sandbox Code Playgroud) 当我试图在php中向服务器发送请求时,似乎我遇到了问题.http api请求是这样的:
http://api.ean.com/ean-services/rs/hotel/v3/avail?minorRev14&apiKey=p9ycn9cxb2zp3k3gfvbf5aym&cid=55505&locale=en_US&hotelId=122212&stateProvinceCode=%20NV%C2%A4cyCode=USD&arrivalDate=12/27/2012&departureDate=12/28/2012&room1=2,&room2=2,18,15&room3=3,16,16,15&room4=3,&includeDetails=true&includeRoomImages=true
我在php中有以下部分代码,我相信错误发生了:
$url = 'http://api.ean.com/ean-services/rs/hotel/v3/avail?minorRev14';
$url .= '&apiKey=p9ycn9cxb2zp3k3gfvbf5aym';
$url .= '&cid=55505';
$url .= '&locale=' . $locale . '&hotelId=' . $hotelid . '&stateProvinceCode=' . $state . '¤cyCode=USD';
$url .= '&arrivalDate=' . $datefr . '&departureDate=' . $dateto . '&' . $details . '&includeDetails=true&includeRoomImages=true';
$header = "Accept: application/json";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$retValue = curl_exec($ch);
$response = json_decode(curl_exec($ch));
$ee = curl_getinfo($ch);
print_r($ee);
print_r($retValue);
Run Code Online (Sandbox Code Playgroud)
这是我从print_r(curl_getinfo($ ch))语句得到的:
Array ( …Run Code Online (Sandbox Code Playgroud) 在我的Symfony2应用程序中,我想用一条路线制作四个网址:
我的路线目前看起来像这样:
report:
pattern: /report/{days}
defaults: { _controller: "AppReportBundle:Report:dayReport", days = null }
Run Code Online (Sandbox Code Playgroud)
该行动定义为:
public function dayReportAction($days = null)
{
// my code here
}
Run Code Online (Sandbox Code Playgroud)
这当前使url 1和2工作,但在url 3和4的情况下,我收到错误
路线未找到
如何使参数"days"可选?
如果没有提供参数,我怎么能允许/省略?
我的symfony2项目有以下问题:
这是我的控制器的代码
public function showCustomerAction($id) {
// retrieve the customer from the database
$em = $this->getDoctrine()->getManager();
$customer = $em->getRepository('VictorIoSiteBundle:Customer')->find($id);
//throw new \Exception($customer);
return $this->render('VictorIoSiteBundle:Site:viewCustomer.html.twig', array('customer' => $customer));
}
Run Code Online (Sandbox Code Playgroud)
我的树枝视图的代码(很简单):
{% if customer is defined %}
<h3>Customer: {{ customer }} </h3>
{% endif %}
Run Code Online (Sandbox Code Playgroud)
最后我的routing.yml
victor_io_site_show_customer:
pattern: /show-customer/{id}
defaults: { _controller: VictorIoSiteBundle:Site:showCustomer }
requirements:
id: \d+
Run Code Online (Sandbox Code Playgroud)
现在,当我继续
http://localhost/Garage/web/app_dev.php/show-customer/46
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Variable " customer " does not exist in VictorIoSiteBundle:Site:viewCustomer.html.twig at line 2
500 Internal Server Error - Twig_Error_Runtime
Run Code Online (Sandbox Code Playgroud) 我试着注入模板服务,这就是我得到的.
<service id="myproject_notification.service.mail" class="%myproject_notification.service.mail.class%">
<argument type="service" id="mailer" />
<argument type="service" id="templating" />
</service>
Run Code Online (Sandbox Code Playgroud)

如果我从依赖项中评论或删除模板服务,一切都运行良好.我看到了关于这个问题的老问题,但似乎我是目前唯一遇到这个问题的人.难道我做错了什么?
Composer.json
"symfony/symfony": "~2.4",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~3.0",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0",
Run Code Online (Sandbox Code Playgroud)
Composer.lock
"name": "symfony/symfony",
"version": "v2.5.0",
...
"name": "twig/twig",
"version": "v1.15.1",
Run Code Online (Sandbox Code Playgroud) 我的代码存在很大问题,我正在尝试检查cookie是否存在,如果确实存在,我不希望它做任何事情.
它在page1上运行正常,但是当我导航到page2时它会覆盖cookie,而不是什么都不做(页面来自同一个网站)
继承我的剧本
function setCookie(c_name, value, exdays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
document.cookie = c_name + "=" + c_value;
}
function getCookie(c_name) {
var i, x, y, ARRcookies = document.cookie.split(";");
for (i = 0; i < ARRcookies.length; i++) {
x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
x = x.replace(/^\s+|\s+$/g,"");
if (x == c_name) {
return unescape(y);
}
}
} …Run Code Online (Sandbox Code Playgroud) symfony ×6
php ×4
twig ×2
cloudcontrol ×1
composer-php ×1
cookies ×1
css ×1
curl ×1
javascript ×1
routing ×1
silex ×1
url ×1