I am currently trying to use the following Stripe plugin for CakePHP 2.x:
https://github.com/chronon/CakePHP-StripeComponent-Plugin
I have created a Shell Command that tries to utilise one of the functions of the Stripe Library.
my bootstrap is as below:
App::import('Vendor', array('file' => 'autoload'));
CakePlugin::load('Stripe');
and I have defined the following at the header of the Shell Command:
App::uses('Shell', 'Console');
App::uses('Controller', 'Controller');
App::uses('ComponentCollection', 'Controller');
App::uses('StripeComponent', 'Stripe.Controller/Component');
Finally, in the main function, I have written the following:
$collection = new ComponentCollection();
$StripeComponent = new StripeComponent($collection);
$controller = new Controller();
$StripeComponent->initialize($controller);
$sub = $StripeComponent->stripeFunction($data);
When I am executing the command, the following error appears:
PHP Fatal error: Class 'Stripe' not found in /var/www/html/myapp/app/Plugin/Stripe/Controller/Component/StripeComponent.php on line 367 Fatal error: Class 'Stripe' not found in /var/www/html/myapp/app/Plugin/Stripe/Controller/Component/StripeComponent.php on line 367 Fatal Error Error: Class 'Stripe' not found in [/var/www/html/myapp/app/Plugin/Stripe/Controller/Component/StripeComponent.php, line 367]
The error appears to be causing problems on this line in StripeComponent, which appears to indicate that the plugin is not loaded during the execution of the command:
Stripe::setApiKey($this->key);
It seems to appear that the plugin was not correctly loaded when executing the Command (The Plugin works for the rest of the App). Is there something that I am doing incorrectly that affects the loading of the plugin? Or can't shell commands load all of the plugins prior to execution?
Any direction is most appreciated.