CodeIgniter Forums
Missing namespace from composer library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: Missing namespace from composer library (/showthread.php?tid=82099)



Missing namespace from composer library - MarvinKleinMusic - 06-12-2022

Hi everyone,
I'm new to CodeIgniter and I'm testing around with it right now. According to the docs, libraries from composer should be loaded automatically.
https://codeigniter4.github.io/CodeIgniter4/concepts/autoloader.html
I've run this composer command to add a Steam login library.
Code:
composer require vikas5914/steam-auth:1.*
However, I'll get this error:
Code:
Class "App\Controllers\Vikas5914\SteamAuth" not found

The according line in my project is the object creation from SteamAuth:

Code:
$steam = new Vikas5914\SteamAuth($config);


Do I'll need  to register the namespaces from the package somewhere? The library itself is shown within the vendor folder.

Thanks!


RE: Missing namespace from composer library - kenjis - 06-12-2022

Quote:Do I'll need  to register the namespaces from the package somewhere?

No.

PHP Code:
$steam = new \Vikas5914\SteamAuth($config); 

I recommend you learn PHP namespaces.
https://www.php.net/manual/en/language.namespaces.rationale.php


RE: Missing namespace from composer library - MarvinKleinMusic - 06-13-2022

Oh... Of course, you were right. Didn't saw that it's missing the beginning /. I copied this part from the example readme of the libary itself.

Thanks for pointing it out to me.