I've installed the stripe library with composer, and I have a problem that is only on one page (see picture here :
my code in cancelStripeSubscription.php :
Stripe\Stripe::setApiKey("my key here");
$sub = \Stripe\Subscription::retrieve($getSubId);
$sub->cancel();
I really don't understand why it's not working since it works in other files in the same directory.
error showing : "Fatal error: Class 'Stripe\Stripe' not found in D:\wamp64\www\etape4Prestige\"
Thanks in advance for helping!
You could use autoloader to actually include the Stripe classes...
require_once('vendor/autoload.php');
This should do the trick if the library is installed with composer I guess...
I have also installed and got the same error, You need to call stripe library like below by creating an object of Stripe not by scope resolution operator(::)
$stripe_obj = new Stripe();
$stripe = $stripe_obj->setApiKey(env('STRIPE_SECRET'));
Related
I'm implementing this package following the instructions found here.
In my config, as instructed, I have
'wiki'=>[
'class'=>'asinfotrack\yii2\wiki\Module',
'processContentCallback'=>function($content) {
//example if you want to use markdown in your wiki
return Parsedown::instance()->parse($content);
}
]
I am getting an error on wiki/content/view?id=index: Class 'app\modules\wiki\Module' not found - what have I missed?
It looks like there is wrong class namespace used in the package by the developer i.e app\modules\wiki\Module instead of asinfotrack\yii2\wiki\Module
to fix this issue without changing the code in the vendor you can set the classmap on top of the project config file( common.php or main.php ) like this
Yii::$classMap['app\modules\wiki\Module'] = VENDOR_PATH.'/toasinfotrack/yii2-wiki/Module.php';
More details about classmapping in Yii2 can be found here
When creating a Client in Evernote sandbox sample:
$client = new \Evernote\Client($token, $sandbox);
I'm getting following error:
Fatal error: Class 'Psr\Log\NullLogger' not found in C:\xampp\htdocs\evernote\evernote-cloud-sdk-php\src\Evernote\Client.php on line 156
I know, this is because of missing: Psr\Log, files but I do not know where I should add them?
I don't want to use composer because I'm not sure if I will be able to use it in production. Anyway the settings is as follows: https://github.com/evernote/evernote-cloud-sdk-php/blob/master/composer.json
Does anyone know how to add the Psr\Log into Evernote PHP SDK API please?
Thank you!
After some testing I found the solution as follows:
download ZIP file of: Psr\Log, from: https://github.com/php-fig/log
save folder: Psr, into folder: evernote-cloud-sdk-php/src
change file: autoload.php, within folder: evernote-cloud-sdk-php/src, as follows:
Add new value into array:
$namespaces = array(
'EDAM',
'Thrift',
'Evernote',
'Psr'
);
Create new function:
function psrAutoload($className, $lastNsPos)
{
return genericAutoload($className, $lastNsPos);
}
Seems to be working so far, hope it will help someone to safe time.
I have used composer to download the Angell EYE PayPal library into my vendor directory. Now I'm trying to call the class within a controller.
I've tried various methods:
Use \angelleye\PayPal;
at the top of page. I've tried using the require() method.
Within the controller I have used
$paypal = PayPal::PayPal($payment);
And a few other ways, but I just get the error Class not found at line 179 and I'm not sure why.
You just need to load a config file (depending on your framework) and the autoloader.
require_once('includes/config.php');
require_once('vendor/angelleye/paypal-php-library/autoload.php');
Of course, adjust the paths to suit where you have those saved, but the autoloader is what makes the classes available to you.
If you want more direct help you can submit a ticket here.
Thanks for response.
I actually managed to get it working on the framework.
I did nt have to load anything or require the class as the composer autoload must do it for me in the framework.
I simply added :
$PayPal = new \angelleye\PayPal\PayPal($PayPalConfig);
and it started to work.
Im guessing if i want to use the PayFlow i would call using:
$PayPal = new \angelleye\PayPal\PayFlow($PayPalConfig);
I will definately post back if the rest of the proccess fails to work.
I am trying to use the Parse.com SDK with PHP. I have downloaded and installed the SDK and I have successfully created a test object.
However, when trying to retrieve an object with a basic query using the sample code provided in the Parse docs and when I try to run it I get:
Fatal Error: Class 'ParseQuery' not found in /home/jameshilton/public_html/index.php on line 109
I would have guessed that it is not linking to the SDK properly but everything else is working fine.
Any ideas what I'm doing wrong?
By looking at the code of the class ParseClient in on GitHub I can see that the classes are declared in the namespace parse. So when you need an object from the Parse library you need to select the namespace. This can be done in two ways.
At the top of your file write:
use \parse;
or when instantiating the class:
$query = new \parse\ParseQuery
And remember to make sure the files are included either through an autoloader (composer?) or manually using include or require.
Regards.
I'm attempting to implement https://github.com/PHP-FFMpeg/PHP-FFMpeg
I copied the src/FFMpeg folder to my includes folder and made sure my autoloader knows where to find everything.
as a test I made a script that simply does:
$ffmpeg = FFMpeg\FFMpeg::create();
$video = $ffmpeg->open('video.mpg');
I get:
Fatal error: Class 'Doctrine\Common\Cache\ArrayCache' not found in /var/www/php/include/FFMpeg/FFProbe.php on line 203
My question is: does PHP-FFMPeg require Doctrine, because that is not stated in the documentation. What version do I need? Are there other prerequisites?
I could create a new question for this, but I'm not sure if I should. I now have PHP-ffmpeg implemented. I'm using Laravel, however that should be irrelevant for this question. I'm trying to enable progress monitoring. It works, however I need to pass in an ID so I can update the correct key in memcache.
$id = 12345;
$format->on('progress', function ($audio, $format, $percentage) {
//this works perfect, but doesn't tell me which item is being updated
Cache::put("progress", $percentage, .25);
//this does not work as I am unable to pass in $id, if I add it as the 4th argument above it will display the number of threads or something
//Cache::put("{$id}_progress", $percentage, .25);
});
I need clarification on the "on" method. I looked through https://ffmpeg-php.readthedocs.org/en/latest/_static/API/ and was not able to figure out how this method works. Any help would be appreciated.
You should follow the recommended instructions in the README.
Composer is the easiest way to install PHP-FFMpeg dependencies
The "on" method called on the format is an implementation of EventEmitter.
As you can see here : https://ffmpeg-php.readthedocs.org/en/latest/_static/API/FFMpeg/Format/ProgressableInterface.html it extends the EventEmitterInterface of https://github.com/igorw/evenement.
If you're really interested about how it works under the hood, have a look at here :
The progress listener is created here : https://github.com/PHP-FFMpeg/PHP-FFMpeg/blob/master/src/FFMpeg/Format/Audio/DefaultAudio.php#L96 and added at execution here https://github.com/PHP-FFMpeg/PHP-FFMpeg/blob/master/src/FFMpeg/Media/Video.php#L151
This is actually possible because FFMpegDriver extends the Driver provided by https://github.com/alchemy-fr/BinaryDriver
Hope this helps :)