Welcome Guest, Not a member yet? Register   Sign In
Problem with load lib
#1

(This post was last modified: 03-24-2023, 05:23 AM by mazz.)

Hi, 
I need to use this library: https://github.com/PayU-EMEA/openpayu_php
so I installed it with this command:

Quote:composer require openpayu/openpayu


In controller I have this code: 
PHP Code:
<?php

namespace App\Controllers;

use 
CodeIgniter\Controller;
use 
OpenPayU_Configuration;

class 
Home extends Controller {

    public function index() {
      
      OpenPayU_Configuration
::setEnvironment('sandbox');
      
    
}



I have this error:
Quote:Class "OpenPayU_Configuration" not found

Should I add something to Config/Autoload.php?


@edit: 
I added this to config/Autoload.php:
PHP Code:
public $psr4 = [
        APP_NAMESPACE          => APPPATH// For custom app namespace
        'Config'                => APPPATH 'Config',
        'PHPMailer\PHPMailer'  => ROOTPATH 'vendor/phpmailer/phpmailer/src',
        'OpenPayU'              => ROOTPATH 'vendor/openpayu/openpayu/lib/OpenPayU'
]; 

In Controller I have:
PHP Code:
use OpenPayU\Configuration as OpenPayU_Configuration

and error is still.
Reply
#2

Solution

In controller I have:

PHP Code:
use OpenPayU_Configuration;
use 
OpenPayU_Order;

...

$openPayUConfig = new OpenPayU_Configuration(); 
$openPayUConfig->setEnvironment('sandbox'); 


and it works!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB