Welcome Guest, Not a member yet? Register   Sign In
$psr4 Namespace Paths
#1

Ok, this one is bending my noobie-brain…

I’ve been experimenting with the $psr4 namespace, and, for demonstrating my problem, have the following (in Autoload.php):

Code:
$psr4 = [
          'Config'     => APPPATH . 'Config',
          'App'        => APPPATH,
          'Libraries'  => APPPATH . 'Libraries',
];

So one may be mistaken to believe that Libraries would be mapped (in the namespace and also in the file structure on the drive) as a sub-directory of the APPPATH (\app)…but if I use it as I’d have expected:

Code:
use Libraries\Functions;

// or, in case anyone thinks it’s now being referenced relative to \Config, the same happens with:
use \Libraries\Functions;

I get:  “Error: Class 'Libraries\Functions' not found”.

If, however, I precede the reference to use with “\App”, as in:

Code:
use \App\Libraries\Functions;

everything works.

So the $psr4 definition doesn’t seem to be doing anything… indeed, if I remove ‘Libraries’ from Autoload.php, it makes no difference, and everything works without it.

What am I missing?

Thanks.

Gary
Reply


Messages In This Thread
$psr4 Namespace Paths - by Gary - 02-24-2020, 05:57 AM
RE: $psr4 Namespace Paths - by InsiteFX - 02-24-2020, 08:55 AM
RE: $psr4 Namespace Paths - by captain-sensible - 02-24-2020, 11:15 AM
RE: $psr4 Namespace Paths - by Gary - 04-13-2020, 12:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB