1

I have run the following command to install Stripe on Yii2:

composer require stripe/stripe-php

The Stripe documentation states to create a config.php file calling the library like this:

require_once('vendor/autoload.php'); 

However it does not worked, so I changed to

require_once('../vendor/stripe/stripe-php/lib/Stripe.php');

And I got the following error:

yii\base\View::main(): Failed opening required '../vendor/stripe/stripe-php/lib/Stripe.php' (include_path='.:/usr/share/php')"

Any idea of how to call this Stripe library from Yii2?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Jan Beeck
  • 303
  • 8
  • 24

1 Answers1

1

Yii 2 composer automatically autoloads extension so you don't have to add require.

You can simply use library like:

\Stripe\Stripe::setApiKey();

or with namespace use:

use Stripe\Stripe;

// ...
Stripe::setApiKey();
Bizley
  • 17,392
  • 5
  • 49
  • 59