如何在我的模块中使用NuSoap.php和PSR-4(Drupal 8)?

I create module and want use NuSoap.php file.

bpay
- src
-- Controller
--- BpayController.php
-- Lib
--- NuSoap.php

BpayController.php :

<?php
namespace Drupal\bpay\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\bpay\Lib
usoap;

class BpayController extends ControllerBase {

  private $client;

  public function new() {
    \Drupal::service('page_cache_kill_switch')->trigger();
    $client = new nusoap_client('https://example.org/pgw?wsdl');
    .
    .
    .
  return $build;
  }
}

NuSoap.php :

<?php
namespace Drupal\bpay\Lib;
.
.
.

When I run page, Show this error:

The website encountered an unexpected error. Please try again later. Error: Class 'Drupal\bpay\Controller usoap_client' not found in Drupal\bpay\Controller\BpayController->new() (line 26 of modules\bpay\src\Controller\BpayController.php).

How can I fix this error ?

Hope it will work fine,

  1. I am assuming your class loader is working fine.
  2. Class is defined as same name nusoap_client

Change this to:

use Drupal\bpay\Lib
usoap;

This:

use Drupal\bpay\Lib
usoap_client as nusoap_client;