I have been transferring my PHP server files from windows to ubuntu 14.04 and my script broke...
I'm getting the error when downloading from S3.
$result = $s3->getObject(array(
'Bucket' => AWS_S3_BUCKET,
'Key' => $imgName,
'SaveAs' => $targetPath
)); //the exception is thrown!
The exception message:
Error executing GetObject on http://s3.amazonaws.com/bucket/file AWS
HTTP error: Unable to open ../../downloads/file using mode r+:
fopen(../../downloads/file).
sudo chmod -R 777 wwwfolder didn't work
Any ideas?
** Update **
Found a Hax/Workaround.... adding touch($targetPath) before $s3->getObject method fixes the problem... but why? I tried on different ubuntu server (same version) and there it works (without touch; and i don't know how it was configured..).
What about now? Any ideas?
Related
I'm using PHP to try using the Google Cloud Spanner. I already did the gCloud settings and everything, and that's right. Now I need to make the connection via PHP to do a CRUD with the database that is in Spanner, but the code below always returns the error:
PHP Fatal error: Undefined constant 'Grpc\STATUS_UNKNOWN' in
/xxx/xxxx/www/vendor/google/cloud-spanner/Connection/Grpc.php on line
129
The code I have is:
<?php
require 'vendor/autoload.php';
use Google\Cloud\Spanner\SpannerClient;
/* Error start here */
$spanner = new SpannerClient([
'projectId' => 'my-project-id'
]);
$db = $spanner->connect('instance', 'database');
$userQuery = $db->execute('SELECT * FROM usuario WHERE login = #login', [
'parameters' => [
'login' => 'devteam'
]
]);
$user = $userQuery->rows()->current();
echo 'Hello ' . $user['login'];
The requirements I use in the composer are:
"require": {
"google/cloud": "^0.32.1",
"google/cloud-spanner": "^0.2.2"
}
I noticed that if I enter through the browser, the error presented above continues to appear. If I run the command php teste.php on the terminal, it runs the script correctly, ie, the terminal works and the browser does not.
Google Cloud PHP's spanner client is gRPC only. This means to use it you will need to install the gRPC PHP extension:
pecl install grpc
Once you have done that, add google/proto-client-php and google/gax to your composer.json and run composer update. After this is done, the error will be resolved.
For those wanting more detailed instructions, see this page for installing and enabling gRPC for PHP!
Since you mentioned that it works on CLI but not on browser, I can say that you need to enable the grpc extension on your php web server config.
E.g. Add
extension=grpc.so to your /etc/php/5.6/apache2/php.ini
Today I set up some new PCs with Linux Mint and wanted to get my Magento-SOAP API run locally.
If I run the script:
$client = new SoapClient('http://magento.dev/mageapi/v2_soap/?wsdl', array('login' => 'apiuser', 'password' => '12345678', 'cache_wsdl' => WSDL_CACHE_NONE, 'trace'=>1))
I get an error that it can't reach http://schemas.xmlsoap.org/soap/encoding/
So I tried it with:
php -r "echo file_get_contents('http://schemas.xmlsoap.org/soap/encoding/');" -d allow_url_fopen=1
If I tun it trough the local network I get the warning:
PHP Warning: file_get_contents(http://schemas.xmlsoap.org/soap/encoding/):
failed to open stream: HTTP request failed! in Command line code on line 1
But If I run it through my mobile phone (via tethering) it works just fine.
It does not look like a network, but more like a local DNS-issue. On my MacBook and on my Windows device in the same network it's running fine.
I have a Laravel 5.1 application that I'm trying to deploy on my CentOS 6.4 VPS server. The problem is that I am getting Error 500 when trying to load the page. When I check the error log it shows me this:
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/home/pams/pams_todo_list/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in /home/pams/pams_todo_list/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:87
I have changed the permissions in pams_todo_list/storage and pams_todo_list/vendors to 777 instead of 755 as a test, but no love.
This problem has been solved, thanks to FFForever and lagbox on the Laravel IRC channel.
My owner permissions were wrong. I had inadvertently uploaded the project using the root account. The fix was two fold. First, I setup suPHP as my php handler (I do have root access to this server) through the EasyApache3 UI in WHM. Then I set the owner:
chown -R pams:pams pams_todo_list
Now it works. I cannot say if it would have worked without setting up suPHP, however it was strongly recommended to set that up, so I did.
All,
I am trying to install and get working the progress ODBC driver for Debian.
I have installed the progress driver no problem, however, when I try to connect in PHP using ODBC_Connect I get an error:
Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Can't open lib '/usr/dlc/odbc/lib/pgoe1022.so' : file not found, SQL state 01000 in SQLConnect
Next step was for me to see if the file existed and if that file had all of its dependencies.
So I issued the following command:
ldd /usr/dlc/odbc/lib/pgoe1022.so
And got the following:
linux-gate.so.1 => (0xb773e000)
libpthread.so.0 => /lib/i386-linux-gnu/i686/cmov/libpthread.so.0 (0xb7505000)
libpgicu22.so => not found
libdl.so.2 => /lib/i386-linux-gnu/i686/cmov/libdl.so.2 (0xb7500000)
libstdc++-libc6.2-2.so.3 => not found
libm.so.6 => /lib/i386-linux-gnu/i686/cmov/libm.so.6 (0xb74da000)
libc.so.6 => /lib/i386-linux-gnu/i686/cmov/libc.so.6 (0xb7375000)
/lib/ld-linux.so.2 (0xb773f000)
Now I am stumped! I cannot get hold of the missing files.
Anyone able to assist at all please?
Regards
Col
It is always helpful to mention the versions of Progress, Linux, PHP and so forth that you are using.
Setting that aside for now. You say that you installed the ODBC driver "no problem". To confirm that you have done so and that the problem is external to the ODBC drivers you should first try a test connection with the supplied sqlexp utility.
From a Linux command shell start "proenv". This will properly set all the needed environment. Then run "sqlexp -u username -p password -db dbname -S port#"
That should get you a prompt where you can enter SQL queries etc.
If that works then you have all of the files needed from Progress' POV and the issue would be in your ODBC setup (odbc.ini). If it does not work then you likely have a Progress/OS release mismatch.
I have configured the openssl with wamp (Apache server). But while I using gdata api I'm getting following error.
( ! ) Fatal error: Uncaught exception 'Zend_Http_Client_Adapter_Exception' with message ' in C:\Zend_1_11_11\library\Zend\Http\Client\Adapter\Socket.php on line 234
( ! ) Zend_Http_Client_Adapter_Exception: Unable to Connect to ssl://accounts.google.com:443. Error #10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\Zend_1_11_11\library\Zend\Http\Client\Adapter\Socket.php on line 234
Somebody help me on this...
Solution only for Windows users:
Check the SSL module is enabled in php.ini:
extension=php_openssl.dll
Answer from Mikhail does not work for me as I run it in Alpine Linux and .dll is only windows extension. Do not use it outside of Windows, it only adds warnings.
Solved my problem:
I had a self-signed certificate that was unable to establish connection.
To check that it is problem you can make a request:
wget way:
// not working:
wget https://accounts.google.com:443
// working:
wget https://accounts.google.com:443 --no-check-certificate
or curl way:
// not working:
curl https://accounts.google.com:443
// working:
curl https://accounts.google.com:443 -k
To temporary solve it in my dev docker container, I have added use of curl adapter and no check for certificate to the code:
$config = array(
'adapter' => 'Zend_Http_Client_Adapter_Curl',
'curloptions' => [CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false]
);
$client = new Zend_Http_Client('https://example.com', $config);
You are behind proxy, so you can not connect directly.Try to use Zend/Http/Client/Adapter/Proxy.php instead of Zend\Http\Client\Adapter\Socket.php
If you on Ubuntu try add in your php.ini
openssl.capath=/etc/ssl/certs
For more info read this issue