Omnipay adds new gateways

Based on this answer: Omnipay how to add a new gateway

I am trying to add a new gateway for omnipay.

My folder structure:




In main composer.json I have:

    "require": {
        "omnipay/omnipay": "dev-master"
    "autoload": {

        "psr-0": { 
            "": "lib/", 
            "Omnipay\\NewGw\\" : "lib/omnipay"


Update composer.

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');



The class is said to be not found:

Omnipay\Common\Exception\RuntimeException: Class '\Omnipay\NewGw\Gateway' not found


I don't understand why the class is not loaded. Please help, thanks.


source to share

1 answer

I just created a new gateway, I believe your problem is 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



All Articles