Trying to access PHP library from within another namespace I'm a little new to the concept of Namespaces in PHP/Drupal, and I'm trying to figure out where I am going wrong here.

I've got this custom PHP library under the /libraries folder - let's call it ilib. And inside of ilib, there is another directory called lms.

Anyway, I've written a little module that will connect with ilib (or I am attempting to get it to connect with it), called ilib_connect.

I am trying to do a test function inside a custom page with a controller for the page, as such:

namespace Drupal\ilib_connect\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use ilib\lms;

/**
 * Controller routines for page example routes.
 */
class iLibController extends ControllerBase {

function ilib_connect_test() {
  $lms = new \ilib\lms;
  \Drupal::logger("ilib_connect")-&gt;notice("&lt;pre&gt;" . $lms . "&lt;/pre&gt;");
  $lms-&gt;AddLMSActivity();
  return "fake markup";
  }

}


However I am getting the error:

Error: Class 'ilib\lms' not found in Drupal\ilib_connect\Controller\iLibController-&gt;ilib_connect_test() (line 17 of modules/custom/ilib_connect/src/Controller/iLibController.php).


So I'm sorta having trouble pulling any classes from ilib into scope.

How exactly do I pull a third party library into scope in a situation like this? What about in a .module file?

What exactly am I misunderstanding here?

EDIT: Oh and just to be clear, this is how I am registering the custom library with Composer:

"autoload": {
"psr-4": {"ilib\\": "web/libraries/ilib"}
}


EDIT 2 - question to Clive:

Ah, so say I've got a file named AddLMSActivity.php inside of libraries/ilib/lms, setup like this:

namespace ilib\lms;

class AddLMSActivity
{

}


How would I access it exactly?

ilib\lms\AddLMSActivity?
When you use use you need to provide namespace + classname. This is what you are doing already, so

use ilib\lms;

Should be replaced with

use ilib\lms\AddLMSActivity;

If you want to use the AddLMSActivity class.