I have a php class that is using Client from Guzzle 6 and composer but when I try to load my page I get an error saying: PHP Fatal error: Interface 'GuzzleHttp\ClientInterface' not found even though I am importing the correct class. When I ctrl click the use statement it takes me directly to the ClientInterface.php in Guzzle. I am unsure why I am getting the PHP error. Any ideas? I tried importing and including, neither works.
Method 1:
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
Method 2:
require_once 'vendor/guzzlehttp/guzzle/src/Client.php';
require_once 'vendor/guzzlehttp/guzzle/src/ClientInterface.php';
I have to check the InAppPurchases receipts with my PHP server.
I would use this script in order to achieve my goal.
I'm running on a shared hosting server, so I'm not able to install or use composer. How can I still use and include the above mentioned PHP script?
I already included the following lines:
require '../lib/validate_inapp_purchase/iTunes/PurchaseItem.php';
require '../lib/validate_inapp_purchase/iTunes/Response.php';
require '../lib/validate_inapp_purchase/iTunes/Validator.php';
use ReceiptValidator\iTunes\Validator as iTunesValidator;
But the script throws the following error:
Fatal error: Class 'GuzzleHttp\Client' not found in /homepages/11/htdocs/app/lib/validate_inapp_purchase/iTunes/Validator.php on line 130
Use composer locally (on your machine) and then upload everything (including vendor folder) to the hosting server.
I want to run Guzzle on Xampp server, but when I try to run it, I get message:
Fatal error: Class 'Guzzle\Http\Exception\BadResponseException' not found in D:\2 Workspace\5 Aptana\OpenTok\Guzzle\Http\Exception\ClientErrorResponseException.php on line 8
I need it as a part of PHP API for OpenTok project. I can't use composer, so I downloaded it manually, but it doesn't work. I think it can be something with namespace and use.
What should I do to get this working?
I'm new to Zend and am currently trying to use Swift Mailer as my messaging system. However, I keep getting this error:
Fatal error: Class 'Adviser\Controller\Swift_Message' not found
I did some research and thought it might be an autoloader issue. So I added the following two lines:
$autoloader = new StandardAutoloader();
$autoloader->registerNamespace('Swift_','/Applications/MAMP/htdocs/zsa/Swift-4.3.0/lib/classes/Swift');
I'm still getting the error. I've also set the path accordingly to "swift_required.php"
require_once '/Applications/MAMP/htdocs/zsa/Swift-4.3.0/lib/swift_required.php';
Any thoughts on how to fix this?
It looks like Swift is not namespaced, so you should use $autoloader->registerPrefix instead if available.
Using http://getcomposer.org/ is a good option too.
Ok. I have used the apparently working code(the main top answer with 136 green ticks):
Send email using the GMail SMTP server from a PHP page
in my php mail script, replacing the gmail user and pass with my own... at first I got errors that PEAR, then PEAR5 could not be found... so I copied those 2 files(I downloaded from pear site) into the script's folder...
Still, script didn't work.
I added some echoes to see where it halts, and it halts at this line(I think):
$mail = $smtp->send($to, $headers, $body);
My apache/php error log says this:
PHP Fatal error: Call to undefined method PEAR_Error::send()`
I have googled this error and found over a dozen pages but havn't found an anwser... mostly they seem to say something about "installing pear libraries."
I have not tried installing/configuring pear on my local server.... because I do not think I can install new packages on my webhost, so I need a more portable solution:
What I mean by this is a working script, and any relative class files I can just copy all into one folder to get it working..... so I can just copy this folder to any apache/php server and it will automatically work(by refrencing the script in html form), without having to install/configure some third party package on the server.
I also tried phpmailer which gave similar problems and it seems to also require pear so I don't really see the point of experimenting with phpmailer further if I cannot get pear to even work.
PHP Fatal error: Call to undefined method PEAR_Error::send()
This means you didn't get a mail object but an error object, probably because logging in failed or so. Add the following to your code:
$mail = Mail::factory(..);
if (PEAR::isError($mail)) {
echo $mail->getMessage() . "\n" . $mail->getUserInfo() . "\n";
die();
}
$mail->send(...);
Btw, using $searchengine to look for that error message would have given you the same answer.
As #cweiske states, adding the code provided by him will give the detailed error. In my case it is Unable to find class for driver smtpPHP Fatal error: Call to undefined m
ethod PEAR_Error::send()
So basically it attempted to include "Mail/smtp.php" and checkd for the Mail_smtp class, but was unable to find it. So either Mail/smtp.php doesn't exist, or including it did not define the Mail_smtp class.
To resolve this all you need to do is to download Pear mail from here and copy the mail folder on to your domain. that's it. your code should work without any issues.
Thanks that helped lead me to this error:
Unable to find class for driver smtp
Which led me to this page:
http://goonanism.com/blog/2010/06/08/using-pear-to-send-email-via-smtp/
which told me I needed additional files. after I added the files it worked.
Issue solved. But I think the requirement of those files should be documented better for people who want portable solutions like myself :)