$ php ./fopen_google.php
<?php
$url = 'https://www.google.com'; //this doesn't work, https!
#$url = 'http://www.cmsrs.pl'; //this work with: http
$fp = fopen($url, 'r');
var_dump( $fp );
?>
And give me error:
PHP Warning: fopen(https://www.google.com): failed to open stream: Connection timed out in ./fopen_google.php on line 5
I have no idea why I have got this error, I try use curl and also set:
set_time_limit(10);
ini_set('max_execution_time', 300);
But I have got still the same error.
This is my curl code that, give me content of google:
<?php
$url = 'https://www.google.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$retval = curl_exec($ch);
print_r($retval);
?>
So I think I haven't got problem with connection, but something wrong with php fopen and ssl
I use
$ php -v
PHP 7.2.24-0ubuntu0.18.04.4 (cli) (built: Apr 8 2020 15:45:57) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24-0ubuntu0.18.04.4, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
$ php -i | grep ssl
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2
openssl
Openssl default config => /usr/lib/ssl/openssl.cnf
openssl.cafile => no value => no value
openssl.capath => no value => no value
My main problem is install 'laravel/ui' into my private project it is:
$ composer require laravel/ui
In RemoteFilesystem.php line 515:
The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Connection timed out
require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...
I have got the same error when I use "fopen" to download google.com content.