Reputation: 31
Based on this answer: Omnipay how to add new gateway
I try to add a new gateway for omnipay.
My folder structure:
lib/omnipay/newgw/
lib/omnipay/newgw/src/
lib/omnipay/newgw/src/Gateway.php
lib/omnipay/newgw/composer.json
vendor/omnipay/...
...
composer.json
In main composer.json I have:
{
"require": {
...
"omnipay/omnipay": "dev-master"
...
},
"autoload": {
"psr-0": {
"": "lib/",
"Omnipay\\NewGw\\" : "lib/omnipay"
}
}
}
Do composer update.
In gateway.php:
namespace Omnipay\NewGw;
use Omnipay\Common;
use Omnipay\Common\AbstractGateway;
use Omnipay\NewGw\Message\PurchaseRequest;
use Omnipay\NewGw\Message\RefundRequest;
class Gateway extends AbstractGateway{
}
And when I try to run it:
use Omnipay\Omnipay;
class TestController extends ControllerBase{
public function index(){
$gateway = Omnipay::create('NewGw');
}
}
It say's that class not found:
Omnipay\Common\Exception\RuntimeException: Class '\Omnipay\NewGw\Gateway' not found
I don't figure it out why the class isn't loaded. Please help, Thanks.
Upvotes: 3
Views: 1239
Reputation: 9357
I just created a new Gateway myself, I believe your problem is the fact that you are doing something like
"psr-0": {
"": "lib/",
"Omnipay\\NewGw\\" : "lib/omnipay"
}
And it should be
"Omnipay\\NewGw\\" : "lib/omnipay/src"
You are setting the namespace of the new library to lib/omnypay but it should actually be lib/omnypay/src
Upvotes: 1