我在 KnpSnappy Bundle 文档中遗漏了一些内容。:( 如何使用 Symfony 和 KnpSnappy 将我的 pdf 保存到服务器。我不希望我的 pdf 下载到浏览器。我希望它保存到服务器。请帮忙!非常感谢。
Server Path: $pdfFolder = $_SERVER['DOCUMENT_ROOT'].'/symfonydev/app/Resources/account_assets/'.$account_id.'/pdf/';
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($content),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="'.$pdfFolder.''.strtotime('now').'.pdf"'
)
);
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用symfony2进行composer安装.但我一次又一次地遇到这个问题.
当我跑:
php composer.php安装
我得到以下错误,我不知道如何解决:
错误#1
[Symfony\Component\Debug\Exception\
ContextErrorException ] 警告:date_default_timezone_get():依赖系统的时区设置是不安全的.您需要使用date.timezone设置或date_default_timezone_set()函数.如果您使用了这些方法中的任何一种并且仍然收到此警告,则很可能拼错了时区标识符.我们现在选择了时区'UTC',但请设置date.timezone以选择您的时区.在/Applications/MAMP/htdocs/ffss/vendor/jms/serializer-bundle/JMS/SerializerBundle/DependencyInjection/Configuration.php第66行
错误#2
脚本Sensio\Bundle\DistributionBundle\Composer\ScriptHandler :: clearCache处理以异常终止的post-install-cmd事件
错误#3
[RuntimeException]
执行"'cache:clear --no-warmup'"命令时发生错误.
这是第1个错误中提到的文件的第66行:
- > scalarNode( 'default_timezone') - >默认值(date_default_timezone_get()) - >端()
谢谢你的帮助!
我有一个AWS S3存储桶,我希望通过url(我的图像和视频链接等)可访问我的大部分文件-这已经完成。我还有其他文件,我不希望通过URL访问,这些文件是音频文件(mp3,wav,flac等)。我只希望用户能够通过将它们提供给浏览器的php脚本来访问我的音频文件。或多或少,我不希望用户通过猜测文件所在的AWS存储桶的URL来访问这些文件。
我很沮丧 谁能指出我正确的方向。谢谢。
我有一个使用 Ubuntu 16 设置的 EC2 服务器,并安装了 LAMP 和 Symfony3。
\n\n服务器在线,所以没有问题。
\n\n我已将我的 Symfony 文件上传到 /var/www/html/project 并成功设置了我的parameter.yml 文件,设置了数据库,并完成了所有安装要求。我已经完成了composer.phar安装,学说:架构:更新等 - 这一切都有效。
\n\n我已将 000-default.conf 更改为以下内容并重新启动了 apache。
\n\n<VirtualHost *:80>\n ServerName site.com\n ServerAlias dev.site.com\n\n ServerAdmin admin@site.com\n DocumentRoot /var/www/html/project/web\n DirectoryIndex app.php\n <Directory /var/www/html/project/web >\n DirectoryIndex app.php\n AllowOverride All\n Allow from All\n </Directory>\n\n # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,\n # error, crit, alert, emerg.\n # It is also possible to configure the loglevel for particular\n # modules, e.g.\n #LogLevel info …Run Code Online (Sandbox Code Playgroud) 我试图生成一个介于0.01 - 0.50之间的随机值进入mysql.我有270万行需要执行此操作.
这是我的脚本:
UPDATE FBAInventory SET buyBox = ROUND( 0.01 + RAND( ) * 8,2 );
Run Code Online (Sandbox Code Playgroud)
它产生的值如4.20,3.89等.我只希望它跨越0.01 - 0.50并且不超过这个值.
有谁知道如何做到这一点?
谢谢!
有没有办法在 Twig 中添加一个空格,其中单词有驼峰字母。
例如:helloWorldHowAreYouDoing 将是hello World How Are You Doing
谢谢!
我正在使用 Symfony2。我试图在 ManyToOne 关联上设置一个 NULL 值,但我不断收到此错误:
ContextErrorException:可捕获的致命错误:传递给 WIC\SettlementBundle\Entity\SettlementReport::setSupplierPayment() 的参数 1 必须是 WIC\SupplierBundle\Entity\SupplierPayment 的实例,给定 null,在 /Applications/MAMP/htdocs/ffss/src 中调用/WIC/SupplierBundle/Controller/SupplierPaymentController.php 第 312 行,定义在 /Applications/MAMP/htdocs/ffss/src/WIC/SettlementBundle/Entity/SettlementReport.php 第 342 行
这是我的结算报告实体中的关联:
/**
* @ORM\ManyToOne(targetEntity="WIC\SupplierBundle\Entity\SupplierPayment", inversedBy="supplierReport")
* @ORM\JoinColumn(name="supplierPayment_id", referencedColumnName="id", nullable=true)
*/
protected $supplierPayment;
Run Code Online (Sandbox Code Playgroud)
下面是 getter 和 setter 方法:
/**
* Set supplierPayment
*
* @param \WIC\SupplierBundle\Entity\SupplierPayment $supplierPayment
* @return SettlementReport
*/
public function setSupplierPayment(\WIC\SupplierBundle\Entity\SupplierPayment $supplierPayment)
{
$this->supplierPayment = $supplierPayment;
return $this;
}
/**
* Get supplierPayment
*
* @return \WIC\SupplierBundle\Entity\SupplierPayment $supplierPayment
*/
public function getSupplierPayment()
{
return $this->supplierPayment; …Run Code Online (Sandbox Code Playgroud) 我正在使用 AWS S3 生成文件的 createPresignedRequest() 。当用户单击在新窗口中打开的链接时,我希望它强制下载。我可以做些什么来启用此功能吗?我已经查看了文档,但没有看到我需要的东西。
这是我创建 url 的代码:
$s3 = new S3Client([
'credentials'=>[
'key'=>$key,
'secret'=>$secret,
],
'region'=>'us-west-2',
'version'=>'2006-03-01',
]);
$cmd = $s3->getCommand('GetObject', [
'Bucket' => $buckname,
'Key' => $file,
]);
$request = $s3->createPresignedRequest($cmd, '+7 days');
$secureUrl = (string) $request->getUri();
echo $secureUrl; // When the user clicks on the link - how can I force download the file instead of open in a new window.
Run Code Online (Sandbox Code Playgroud) 有一个问题,当他们从ajax响应中返回时,如何在Symfony2中正确输出表单提交错误.
我通过ajax发布表单,如果表单没有正确填写,它将使用以下代码发回错误的响应...
$errors = $form->getErrorsAsString();
$return = array("responseCode"=>200, "responseVal"=>"Error", "errorReport"=>$errors);
Run Code Online (Sandbox Code Playgroud)
这将创建一个错误数组和其他变量,如下所示:
{"responseCode":200,"responseVal":"Error","errorReport":"ERROR: Name cannot be blank.\nERROR: Address cannot be blank.\nERROR: City cannot be blank.\nERROR: State cannot be blank.\nERROR: Zip cannot be blank.\nERROR: Phone cannot be blank.\nERROR: Email cannot be blank.\nname:\n No errors\naddress:\n No errors\ncity:\n No errors\nstate:\n No errors\nzip:\n No errors\nemail:\n No errors\nfax:\n No errors\nphone:\n No errors\n"}
Run Code Online (Sandbox Code Playgroud)
然后我使用jQuery将错误写入div,如下所示:
$("#errorReport").html(data.errorReport);
Run Code Online (Sandbox Code Playgroud)
这给了我一个div,内容如下:
ERROR: Name cannot be blank. ERROR: Address cannot be blank. ERROR: City cannot be blank. ERROR: State cannot be blank. ERROR: …Run Code Online (Sandbox Code Playgroud) 我遇到了运行doctrine:schema:update --force的问题,原因是forgeign键约束问题.
[Doctrine\DBAL\DBALException] An exception occurred while executing 'ALTER TABLE Product ADD CONSTRAINT FK_1CF73D312ADD6D8C FOREIGN KEY (supplier_id) REFERENCES Supplier (id) ON DELETE SET NULL':
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`wic_dev`.`#sql-5c0 a_1a12`, CONSTRAINT `FK_1CF73D312ADD6D8C` FOREIGN KEY (`supplier_id`) REFERENCES `Supplier` (`id`) ON DELETE SET NULL)
[PDOException] SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`wic_dev`.`#sql-5c0 a_1a12`, CONSTRAINT `FK_1CF73D312ADD6D8C` FOREIGN KEY (`supplier_id`) …Run Code Online (Sandbox Code Playgroud)