Suppose I run the following in a PHP interactive shell, requiring a utility function file with all code under the namespace utils
:
php > require_once __DIR__ . '/utils.php';
php > echo \utils\doubleMe(2);
4
php > use \utils as u;
php > echo u\doubleMe(2);
PHP Warning: Uncaught Error: Call to undefined function u\doubleMe() in php shell code: 1
Stack trace: ...
php >
I can call the functions using the fully qualified namespace without issue, however, when I try to use
/alias the namespace, it's as if it never happened, and attempts to call functions under the aliased namespace error, saying the function is undefined.
How should I use
a namespace in PHP's Interactive Shell? If it's simply not possible, is there any particular reason why?