CodeIgniter + omnipay安装 [英] CodeIgniter + omnipay installation
问题描述
我已经使用ci-merchant,但从一切看到它的V2现在是万能的。
I have used ci-merchant before but from everything see that the "V2" of it is now omnipay. I use codeigniter and i'm struggling to get even the example to work.
我安装了omnipay没有问题,在我的控制器有以下:
I have installed omnipay no problems and in my controller have the following:
use Omnipay\Common\GatewayFactory;
class Homepage extends BC_basecontroller {
public function index()
{
$gateway = GatewayFactory::create('PayPal_Express');
$gateway->setUsername('adrian');
$gateway->setPassword('12345');
}
}
这里是一个例子: https://github.com/adrianmacneil/omnipay
但是我得到错误:
PHP Fatal error: Class 'Omnipay\Common\GatewayFactory' not found in......
有没有人知道如何让它在CI工作?
Does anyone know how to get it to work in CI?
推荐答案
我不知道你是如何安装Omnipay的,但你需要使用 Composer 加载类,然后才能使用它们。
I'm not sure how you installed Omnipay, but you need to use Composer to load the classes before you can use them.
按照 Omnipay安装说明,将其添加到根目录中的 composer.json
文件中:
So following the Omnipay installation instructions, add this to a composer.json
file in your root directory:
{
"require": {
"omnipay/omnipay": "*"
}
}
然后安装文件:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update
现在,如果使用CodeIgniter,以将其设置为包括composer自动加载器。基本上,只需将此行添加到 index.php
文件的顶部:
Now, if you are using CodeIgniter you will need to set it up to include the composer autoloader. Basically, just add this line to the top of your index.php
file:
require_once __DIR__.'/vendor/autoload.php';
还有一个关于使用Composer和CodeIgniter的教程,您可能会发现这有帮助: http://philsturgeon.co.uk/blog/2012/05/composer-with-codeigniter
There is also a tutorial on using Composer with CodeIgniter here which you may find helpful: http://philsturgeon.co.uk/blog/2012/05/composer-with-codeigniter
这篇关于CodeIgniter + omnipay安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!