草庐IT

basic-setup-with-three-boxes

全部标签

php - curl 错误 28 : Operation timed out after 2000 milliseconds with 7276200 out of 23000995 bytes received

描述我在Laravel项目中使用Guzzle。当我向返回大量有效负载的API发出请求时,我遇到了内存崩溃。我在CURL.php类的顶部有这个。我有使用Guzzle的get()。useGuzzleHttp\Exception\GuzzleException;useGuzzleHttp\Client;useGuzzleHttp\FORCE_IP_RESOLVE;useGuzzleHttp\DECODE_CONTENT;useGuzzleHttp\CONNECT_TIMEOUT;useGuzzleHttp\READ_TIMEOUT;useGuzzleHttp\TIMEOUT;classCUR

php - laravel 在创建父模型后使用 with() vs load() 进行预加载

我正在创建一个Reply模型,然后尝试返回对象及其owner关系。以下是返回空对象的代码://file:Thread.php//thisreturnsanemptyobject!!??publicfunctionaddReply($reply){$new_reply=$this->replies()->create($reply);return$new_reply->with('owner');}但是,如果我将with()方法换成load()方法来加载owner关系,我会得到预期的结果.即回复对象及其关联的owner关系返回://thisworks{$new_reply=$this->

php - 正则表达式 : Converting non-block elements with <br/> to <p> in PHP

有人问了similarquestion,但接受的答案不符合我的要求。输入:boldtextlinksomecodeI'masinglebr,leavemealone.预期输出:boldtextlinksomecodeI'masinglebr,leavemealone.我上面提到的接受的答案将多个br转换为p,最后用另一个p包装所有输入。但就我而言,您不能将pre包装在p标签内。谁能帮忙?更新此编辑之前的预期输出有点令人困惑。重点是:将多个br转换为一个(使用preg_replace('/()+/','',$str);实现)检查内联元素和未包装的文本(在这种情况下没有父元素,输入来自$_

php - Symfony2 和 Twig 在 vagrant box 中的表现

先决条件:http://box.scotch.io/Vagrant盒2.#-*-mode:ruby-*-#vi:setft=ruby:Vagrant.configure("2")do|config|config.vm.box="scotch/box"config.vm.network"private_network",ip:"192.168.33.10"config.vm.network"forwarded_port",guest:80,host:80config.vm.network"forwarded_port",guest:3306,host:3306config.vm.netw

php - 使用 Box.com PHP API 上传文件

我正在尝试使用BoxAPI将文件上传到box.com。根据文档,curl请求必须如下所示:curlhttps://upload.box.com/api/2.0/files/content\-H"Authorization:BearerACCESS_TOKEN"-XPOST\-Fattributes='{"name":nameOftheFile,"parent":{"id":parentId}}'\-Ffile=@file这是我做的:$token="......";$url=https://upload.box.com/api/2.0/files/content;$file_upload

php - 压缩存档 PHP : Close() returns false with no error message

我正在尝试使用基于数组结构的目录树创建一个zip文件。我已经在使用thisanswer当我需要从目录树创建一个zip文件时,但在这种情况下,所有文件都在同一目录中,目录树基于数据库中的其他数据。我已经检查过所有文件都在正确的路径中,并且foreach循环正在运行。$zip->close发生错误。这就是代码(原始数组在每一层都有很多条目):$zip_array=array('Level1'=>array('Level2'=>array('file1'=>'/var/www/html/pdf/683026577.pdf','file2'=>'/var/www/html/pdf/683026

php - 单元测试 : Simulate a timeout with Guzzle 5

我正在使用Guzzle5.3并想测试我的客户端是否抛出TimeOutException。那么,我如何模拟GuzzleClient并抛出GuzzleHttp\Exception\ConnectException?要测试的代码。publicfunctionrequest($namedRoute,$data=[]){try{/**@noinspectionPhpVoidFunctionResultUsedInspection*//**@var\GuzzleHttp\Message\ResponseInterface$response*/$response=$this->httpClient-

PhpStorm:获取 "Methods with the same name as their class will not be constructors"的代码检查警告

好吧,我终于切换到PHP7。我的代码有点旧,会被翻新。一些问题是:classMagicClassfunctionMagicClass(){//etc}在执行过程中给出弃用警告:Deprecated:MethodswiththesamenameastheirclasswillnotbeconstructorsinafutureversionofPHP;MagicClasshasadeprecatedconstructorin这很好:classMagicClassfunction__construct(){//etc}如何让PhpStorm代码检查来警告我当前代码库中的此类错误?

PHP header (位置 :) redirect with root directory

有没有办法创建从根目录开始的header('Location:');路径。例如:formaction="/cert/forms/sessions/session-inc-info.php"或include($_SERVER['DOCUMENT_ROOT'].'/cert/forms/sessions/session-inc-info.php');cert是我的根目录文件夹我一直在尝试这样的代码header('Location:'.$_SERVER['DOCUMENT_ROOT'].'/cert/forms/sessions/session-inc-info.php);和header('

PHP7 : Methods with a scalar type declaration refuse to type juggle NULL values, 即使在弱/强制模式下

截至PHP7.0,标量类型提示int、float、string和bool可以包含在方法签名中。默认情况下,这些类型声明以弱/强制模式(或“typejuggling”模式)运行。根据PHPmanual:PHPwillcoercevaluesofthewrongtypeintotheexpectedscalartypeifpossible.Forexample,afunctionthatisgivenanintegerforaparameterthatexpectsastringwillgetavariableoftypestring.但即使可以将NULL强制转换为整数0,具有int类型提