php-7

Pecl install sqlsrv returns No releases available for package

蓝咒 提交于 2021-01-27 19:34:00
问题 While installing sqlsrv module for PHP7 i'm getting following error - No releases available for package "pecl.php.net/sqlsrv Command used sudo pecl install sqlsrv Any idea how to resolve this issue? 回答1: Same problem here... Solved installing modules as root this way (Ubuntu 16.04): wget http://pecl.php.net/get/sqlsrv-4.3.0.tgz pear install sqlsrv-4.3.0.tgz wget http://pecl.php.net/get/pdo_sqlsrv-4.3.0.tgz pear install pdo_sqlsrv-4.3.0.tgz You can check latests available versions here: http:/

PHP Upload File

╄→尐↘猪︶ㄣ 提交于 2021-01-27 14:02:01
问题 I'm trying to upload file to server with php script. I'm Using MAMP with PHP7.0.8 I have HTML form: <form enctype="multipart/form-data" action="hi" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="300000" /> Send File: <input name="userfile" type="file" /> <input type="submit" value="Send File" /> </form> And simple php: <?php $uploaddir = 'img/'; print_r($uploadfile = $uploaddir.basename($_FILES['userfile']['name'])); echo '<pre>'; if (move_uploaded_file($_FILES['userfile'][

PHP 7 SSH2.SFTP stat() bug work around

风流意气都作罢 提交于 2021-01-27 06:19:24
问题 I have an app the uses an SFTP connection to download files. It was working correctly in PHP 5.6, not so much in PHP 7. The error I get is as follows: PHP Warning: filesize(): stat failed for ssh2.sftp ... My code is as follows: public function retrieveFiles($downloadTargetFolder,$remoteFolder = '.') { $fileCount = 0; echo "\nSftpFetcher retrieveFiles\n"; $con = ssh2_connect($this->host,$this->port) or die("Couldn't connect\n"); if($this->pubKeyFile){ $isAuth = ssh2_auth_pubkey_file($con,

PHP Parse error: syntax error, unexpected ':', expecting ';' or '{'

戏子无情 提交于 2021-01-27 06:00:35
问题 I'm try playing with php7. I have installed https://github.com/rlerdorf/php7dev and connected through phpstorm. I'm trying use new feature like this: <?php namespace Kata; class StringCalculator { public function add(string $parameters): int { return 0; } } then I try to test it like this: <?php namespace Kata; class StringCalculatorTest extends \PHPUnit_Framework_TestCase { public function testAddEmptyString() { $calc = new StringCalculator(); $this->assertSame(0, $calc->add('')); } } and I

php 7 file is downloaded instead instead of executing [duplicate]

烂漫一生 提交于 2021-01-27 05:44:12
问题 This question already has answers here : PHP code is not being executed, instead code shows on the page (28 answers) Closed 1 year ago . I recently configured php7 on Ubuntu 14.04 by following blog http://www.zimuel.it/install-php-7 and I installed it successfully as per blog. but when try to run the php file (/var/www/test.php) then it is downloaded instead of executing. I have no idea what configuration I missed. and when I entered localhost in browser then it comes with response "it works"

Swiftmailer - Uncaught Error: Call to undefined method Swift_SmtpTransport::newInstance()

点点圈 提交于 2021-01-21 06:52:29
问题 I'm trying to send email using the Swiftmailer . I'm getting an Uncaught Error: Call to undefined method Swift_SmtpTransport::newInstance(). Here is the code: require_once 'swift/lib/swift_required.php'; $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl') ->setUsername ('email@gmail.com') ->setPassword ('password'); $mailer = Swift_Mailer::newInstance($transport); $message = Swift_Message::newInstance('Weekly Hours') ->setFrom (array('email@gmail.com' => 'My Name')) -

Get the route name in a Symfony service [duplicate]

和自甴很熟 提交于 2020-12-13 03:45:07
问题 This question already has answers here : Getting the route name inside a service in symfony (2 answers) Closed 2 years ago . Im try to get the name of the current route in a Symfony 4 service. routes.yaml test-route: path: /test controller: App\Controller\Test::test service class Myservice { private $u; public function __construct(Utilities $u){ $this->u = $u; $route = getRouteSomehow(); // should return "test-route" } } I found this piece of code to grab the route: $requestStack-

Make phpunit catch php7 TypeError

空扰寡人 提交于 2020-11-30 09:15:30
问题 I am trying to validate that a php7 function accept only integers. This is the class: <?php declare(strict_types=1); class Post { private $id; public function setId(int $id) { $this->id = $id; } } And this is the test: <?php declare(strict_types=1); class PostTest extends \PHPUnit_Framework_TestCase { private function getPostEntity() { return new Post(); } public function testSetId() { $valuesExpected = [123, '123a']; foreach ($valuesExpected as $input) { $this->getPostEntity()->setId($input)

Make phpunit catch php7 TypeError

…衆ロ難τιáo~ 提交于 2020-11-30 09:14:50
问题 I am trying to validate that a php7 function accept only integers. This is the class: <?php declare(strict_types=1); class Post { private $id; public function setId(int $id) { $this->id = $id; } } And this is the test: <?php declare(strict_types=1); class PostTest extends \PHPUnit_Framework_TestCase { private function getPostEntity() { return new Post(); } public function testSetId() { $valuesExpected = [123, '123a']; foreach ($valuesExpected as $input) { $this->getPostEntity()->setId($input)

Make phpunit catch php7 TypeError

孤街浪徒 提交于 2020-11-30 09:13:30
问题 I am trying to validate that a php7 function accept only integers. This is the class: <?php declare(strict_types=1); class Post { private $id; public function setId(int $id) { $this->id = $id; } } And this is the test: <?php declare(strict_types=1); class PostTest extends \PHPUnit_Framework_TestCase { private function getPostEntity() { return new Post(); } public function testSetId() { $valuesExpected = [123, '123a']; foreach ($valuesExpected as $input) { $this->getPostEntity()->setId($input)