Skip to content

Autoloading not functional with custom namespaces outside application dir #529

Description

@timothymarois

This could not be an issue at all, or that I am missing something so trivial and that I am sorry, but from looking at both of these pages, I am unable to replicate the functionality desired here.

https://bcit-ci.github.io/CodeIgniter4/general/modules.html
http://blog.newmythmedia.com/blog/show/2016-03-15_Modules_in_CodeIgniter_4

Added in application/Config/Autoload.php

public $psr4 = [
  'Modules' => ROOTPATH.'modules'
];

Directory exist above the application directory called "modules"

File exists under:
modules/Test/Config/Routes.php

Adding this to the end of the file of application/Config/Routes.php

$files = service('locator')->search('Config/Routes.php');

print_r($files);

foreach ($files as $file)
{
    include_once $file;
}

The print returns array of the application and system Routes.php files, and completely ignored my custom modules/Test/Config/Routes.php

Array ( [0] => ~/application/Config/Routes.php [1] => ~/system/Config/Routes.php )

So from my current tests, I am unable to get custom namespaces (directories) working from the autoload class. Basically its unrecognizable by the psr4 system. So that must be something it can not find within my custom directories?

If anyone can point out a mistake or lead me in the right direction that would be great, otherwise from both of the pages listed above, following the step by step instructions didn't seem to work.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions