Closed crucid closed 12 years ago
The core is never designed to load a config file from a specfic package. The idea is that you just load the config file, and the core will load it. It will always check app and all loaded packages, so there is no need to load it from a package.
The '::' notation was designed to load a config from a loaded by non-active module, for which NO automatic loading mechanism exists. That it (sort of) works for packages too is an unintended side-effect.
The docs (http://docs.fuelphp.com/general/packages.html) specify to use:
where namespace is NOT preceded by a backslash. Other default packages use the same format. However, when trying to load a config file using \Config::load('package::config'), the config is never loaded. After drilling down I found that in \Fuel\Core\Finder on line 303, the logic is:
It prefixes the package/module name with a backslash for namespace lookup. The \Autoloader::namespace_path key-searches the internal namespace array which has the namespaces as keys with NO prefixed backslash (as directed by documentation), thus the namespace is never found and ultimately the config file isn't found.
A consist method of storing namespaces and looking up namespaces needs to be handled. Either backslashes need to be used or not when adding and checking namespaces; the core methods can obviously be modified to handle this. To fix the situation for my project, I went against the documentation and all examples and used
This works because it stores the namespace with the backslash as the key in the internal array so it can be found by \Autoloader::namespace_path. Some of the other \Autoloader functions are "smart enough" to trim off the prefixed backslash.