I'm trying to load the Stripe PHP API (installed via Composer) into my CodeIgniter 4 app. This is what my files look like:
Composer.json
{
"description": "The CodeIgniter framework",
"name": "codeigniter/framework",
"type": "project",
"homepage": "https://codeigniter.com",
"license": "MIT",
"support": {
"forum": "http://forum.codeigniter.com/",
"wiki": "https://github.com/bcit-ci/CodeIgniter/wiki",
"slack": "https://codeigniterchat.slack.com",
"source": "https://github.com/bcit-ci/CodeIgniter"
},
"require": {
"php": ">=5.3.7",
"stripe/stripe-php": "^6.7"
},
"suggest": {
"paragonie/random_compat": "Provides better randomness in PHP 5.x"
},
"require-dev": {
"mikey179/vfsStream": "1.1.*",
"phpunit/phpunit": "4.* || 5.*"
}
}
Autoload.php (only the code that matters)
...
$classmap = ['Stripe' => '../../vendor/stripe/stripe-php/lib/Stripe.php'];
...
MyController.php
public function construct() {
parent::__construct($request, $response, $logger = null);
$this->db = \Config\Services::db();
$this->stripe = Stripe();
}
Running this code gives me: Call to undefined function App\Controllers\Base\Stripe(). I'm pretty sure I set everything up correctly and I'm just not calling Stripe from my controller correctly. I took a look at the CodeIgniter 4 docs but couldn't find any help and since CI4 is so new there's not much online. Any help greatly appreciated!