I'm starting a project with Laravel 6.2, added kreait/laravel-firebase and configured it with the .json configuration file to work with Realtime database and works like a charm.
Later I read that Cloud Firestore is better. So I've installed the library google cloud and use the example provided:
public function test(){
$db = new FirestoreClient();
$docRef = $db->collection('users')->document('aturing');
$docRef->set([
'first' => 'Alan',
'middle' => 'Mathison',
'last' => 'Turing',
'born' => 1912
]);
printf('Added data to the aturing document in the users collection.' . PHP_EOL);
}
That request and every request throws me this exception:
Google\Cloud\Core\Exception\ServiceException
{ "message": "Empty update", "code": 14, "status": "UNAVAILABLE", "details": [] }
I searched the docs, forums, everything and I can't find an answer.
Thanks in advance.
I had the same issue in Laravel, the solution is to pin in composer.json grpc/grpc to version 1.19 and then restart apache.
"require": {
"grpc/grpc": "1.19"
}
More details here: https://github.com/googleapis/google-cloud-php/issues/2539
I got same issue on my local in project laravel with xampp php 7.4 and grpc 1.26 but on my remote server working fine with same version grpc
Related
i'm trying to convert a varity of audio files into a specific audio type of my chossing on my laravel project.
on my search i landed on a package called Laravel FFMpeg, i started with a fresh installation with laravel 6.2, and did the installation as it shows on github, as soon as i started using it i had this error :
FFMpeg\Exception\ExecutableNotFoundException: Unable to load FFMpeg in file C:\Users\Hatim\Desktop\Projects\Audio\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\Driver\FFMpegDriver.php on line 55
#0 C:\Users\Hatim\Desktop\Projects\Audio\vendor\pbmedia\laravel-ffmpeg\src\Support\ServiceProvider.php(61): FFMpeg\Driver\FFMpegDriver::create(Object(Illuminate\Log\LogManager), Object(Alchemy\BinaryDriver\Configuration))
I'm currently just working with a simple thing :
FFMpeg::fromDisk('s3');
and yes I have called it my Controller: use ProtoneMedia\LaravelFFMpeg\Support\FFMpeg;
I have also tried to install the PHP-FFMpeg Package and also tried to install FFmpeg on my device and link it using the path in my config\laravel-FFmpeg
This is how it looks now without any modification, I went to my .env folder but it has nothing regarding FFmpeg so it takes the default value, that's why I tried installing it on my device and replacing the default value with the path of the FFmpeg on my device.
return [
'ffmpeg' => [
'binaries' => env('FFMPEG_BINARIES', 'ffmpeg'),
'threads' => 12,
],
'ffprobe' => [
'binaries' => env('FFPROBE_BINARIES', 'ffprobe'),
],
'timeout' => 3600,
'enable_logging' => true
];
I'm currently working on my local environment, but this has to work on a server.
I have solved the problem, this response is for future developers having a problem with the package.
first of all you have to install FFmpeg on your device, [click me][1]
chose your os and download it, unzip it rename it to FFmpeg, and then copy the folder and place it in your c: folder for example.
after that just go to your config\laravel-FFmpeg file in your project and change the defaults to the exact path in c: folder
'ffmpeg' => [
'binaries' => env('FFMPEG_BINARIES', 'C:\ffmpeg\bin\ffmpeg.exe'),
'threads' => 12,
],
'ffprobe' => [
'binaries' => env('FFPROBE_BINARIES', 'C:\ffmpeg\bin\ffprobe.exe'),
],
Like a suggestions: set in your local .env file:
FFMPEG_BINARIES=C:\bin\ffmpeg.exe
FFPROBE_BINARIES=C:\bin\ffprobe.exe
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
I am trying to write a script to automatically update the nameservers that I registered in Route 53.
This can be done via Amazon Rest API:
http://docs.aws.amazon.com/Route53/latest/APIReference/api-update-domain-name-servers.html
Up to this point, I have been using the Amazon PHP SDK...but this SDK doesn't even have support for this command (or a majority of Route 53 commands).
I've spent hours trying to form a request using php+curl. I have everything I need - an acesskeyID, secret key, etc. No matter what I do I can NOT seem to get the signature to be valid. The docs are a nightmare...everything related to PHP immediately points you to the SDK, which is no help here.
Please show me how to make a REST request with PHP, sign it using my key, and get a response.
Edit: Here is what I tried to follow to sign the request.
Which version of the SDK are you using?
According to api v3 docs you can use this:
$result = $client->updateDomainNameservers([/* ... */]);
$promise = $client->updateDomainNameserversAsync([/* ... */]);
And these are the relevant parameters:
$result = $client->updateDomainNameservers([
'DomainName' => '<string>', // REQUIRED
'FIAuthKey' => '<string>',
'Nameservers' => [ // REQUIRED
[
'GlueIps' => ['<string>', ...],
'Name' => '<string>', // REQUIRED
],
// ...
],
]);
If you are not using the latest version of the sdk you can install it using composer:
php composer.phar require aws/aws-sdk-php
or use any of the installation methods here.
I really think its best for you to stick with the SDK, unless really not possible (which I don't think is the case here, correct me if I'm wrong).
If installed using composer you can update your composer.json file to contain:
{
"require": {
"aws/aws-sdk-php": "3.*"
}
}
and run composer update
If you just want to check which version of the sdk you are working with you can run composer info (inside that directory):
> composer info
aws/aws-sdk-php 3.18.32 AWS SDK for PHP - Use Amazon Web Services in your PHP project
guzzlehttp/guzzle 6.2.1 Guzzle is a PHP HTTP client library
guzzlehttp/promises 1.2.0 Guzzle promises library
guzzlehttp/psr7 1.3.1 PSR-7 message implementation
mtdowling/jmespath.php 2.3.0 Declaratively specify how to extract elements from a JSON document
psr/http-message 1.0 Common interface for HTTP messages
Or check the content of the composer.lock file. You should have there the version of the sdk you are using:
"packages": [
{
"name": "aws/aws-sdk-php",
"version": "3.18.32",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "84b9927ee116b30babf90a9fc723764672543e29"
},
Make sure you use the last one.
Thanks to #Dekel, I was able to solve this problem. Here is my final code.
require_once '/vendor/autoload.php';
$access_key="XXXXX";
$secret_key="XXXXXXXXXXXX";
$client = Aws\Route53Domains\Route53DomainsClient::factory(array(
'region'=> "us-east-1",
'version'=>'2014-05-15',
'credentials' => array(
'key' => $access_key,
'secret' => $secret_key,
)));
$result = $client->updateDomainNameservers([
'DomainName' => 'example.com',
"Nameservers"=>array(
array("Name"=>"ns.1.com"),
array("Name"=>"ns.2.com")
)
]);
I am trying to use Guzzle client to post requests to an API, and I am getting an error message saying,
InvalidArgumentException: "No method is configured to handle the form_params config key"
This is what I have tried:
$response = $this->guzzle->post("https://example.com",[
'form_params'=> [
'client_id'=>$this->client_id,
'authorization_code'=>$this->authorization_code,
'decoder_query'=> $this->requestQuery
],
]
);
$this->requestQuery is a JSON request.
$response = $this->guzzle->post("https://example.com", [
'body' => [
'client_id' => $this->client_id,
'authorization_code'=> $this->authorization_code,
'decoder_query' => json_encode($this->requestQuery),
]
]);
with this syntax I am getting it woking..
you are probably using a Guzzle version that's before 6.0. update to the latest version and 'form_params' will work just fine. i had the same issue since i was on 5.x version
composer require 'guzzlehttp/guzzle:6.0.1'
and make sure you update your dependencies:
composer update
you'll then see it'll pull in "guzzlehttp/psr7 (1.0.0)" as well. hope that helps.
For me, this ended up being an problem with the actual Guzzle package not being correct. It loaded a version from cache that wasn't the the PSR7 version.
After clearing composer cache
php composer.phar clear-cache
I simply did a new composer install and installed just fine, while fixing the error.
Help me out here....
I have installed wkhtml2pdf 0.9.9 static for mac os and installed it in the /usr/bin. Wkhtml2pdf works fine from the terminal, with the wkhtmltopdf [source website][generated file to be saved].
Though I am unable to use it in Symfony 2.3.7, with the knpSnappy and knpSnappyBundle installed. I am sure I have entered everything correctly. I have checked it a million times and searched all of the google and yet couldnt find why it would do that (been searching for two days.
I have downloaded knpSnappy and knpSnappyBundle through composer and it is in the vendor and as well as enabled in the config.yml and added to appkernel.php, other than that Following is my configuration:
Composer:
"knplabs/knp-snappy-bundle": "dev-master",
"knplabs/knp-snappy": "*"
Appkernel:
new Knp\Bundle\SnappyBundle\KnpSnappyBundle(),
Controller:
public function generateAction($date)
{
$em = $this->getDoctrine()->getManager();
$publishedAds = $em->getRepository('pdfRenderAdBundle:Ads')
->getAllAds();
if (!$publishedAds) {
throw $this->createNotFoundException(
'No ads found for today!'
);
}
$html = $this->renderView('pdfRenderAdBundle:Application:generate.html.twig', array(
'publishedAds' => $publishedAds
));
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
400,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="file.pdf"'
)
);
}
SYMFONY VER: 2.3.7
WKHTMLTOPDF: 0.9.9 STATIC OSX KNPSNAPPY LIB &
KNPSNAPPY BUNDLE: THE LATEST ONE THROUGH SYMFONY
Whenever I try to access the controller it gives the:
The process has been signaled with signal "5" - 500 Internal Server Error - RuntimeException
I will really appreciate it if any one of you can help out of this well..... Stuck here for a very long time now.
For anyone else that comes across this, here's the post on how to get this working:
http://oneqonea.blogspot.com/2012/04/why-does-wkhtmltopdf-work-via-terminal.html
Here's the short version:
Comment out the following line in /Applications/MAMP/Library/bin/envvars
#export DYLD_LIBRARY_PATH
And then add this line:
export PATH=/parent/path/of/wkhtmltopdf/executable:$PATH
I had this problem as well, and if IIRC the solution was to use wkhtmltopdf version 0.9.6.