CodeIgniter Forums
How to use package composer in controller (jasig\phpcas)) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: How to use package composer in controller (jasig\phpcas)) (/showthread.php?tid=81927)



How to use package composer in controller (jasig\phpcas)) - aurelyan - 05-23-2022

Hi everyone,
Sorry for my question but i'm struggling with an issu and i unable to reach the solution.
I'd like to use the "jasig\phpcas" package download with composer in my CI4.1.9 recently installed and obviously, i failed. How do i use a package in composer directory ? I thought all composer packages were autoloaded and available for use in controlers directly but when i call :
Code:
phpCAS::client('3.0','my-cas-url',443,'/cas')

The page crash and the log return : " Class "App\Controllers\phpCAS" not found...".
I'd tried to include the class php file from the composer dir or "use \jasig\phpcas" in the begining of my controler but i still have the same result, "phpCAS not found".

Sorry, i'm not an expert with the new CI4 and namspaces PHP. Is anyone can explain how to reach this purpose ?

Thx


RE: How to use package composer in controller (jasig\phpcas)) - iRedds - 05-23-2022

You are trying to access the phpCAS class in the context of the App\Controllers namespace.
That's why you're getting the error.

PHP Code:
// before class
use phpCas
// or use backslash
-> \phpCas::client() 



RE: How to use package composer in controller (jasig\phpcas)) - aurelyan - 05-23-2022

(05-23-2022, 11:31 AM)iRedds Wrote: You are trying to access the phpCAS class in the context of the App\Controllers namespace.
That's why you're getting the error.

PHP Code:
// before class
use phpCas
// or use backslash
-> \phpCas::client() 

Thanks a lot !!
I think i've tried all the pattern but not only 'use phpCAS'... my bad.
It work's now.