我一直在使用phpsh一段时间了,过去它运行得很好.但它的命名空间支持仍然不是很好,这可能非常令人沮丧.
\Somespace\Someclass::someStaticFunction()在没有禁用检查是否存在方法的情况下,这样做是行不通的,这会导致重置环境的拼写错误导致频繁的致命错误.
有多个PHP REPL,包括PHP内置shell(php -a),使用起来很糟糕.
有没有人知道一个替代方案或者一个具有正确名称空间支持的phpsh-fork?或者也许是一个简单的配置修复我忽略了......
一个例子:
这个测试文件:
<?
namespace testing;
function echoSome(){
echo 'Something';
}
\testing\echoSome();
Run Code Online (Sandbox Code Playgroud)
在phpsh中生成此输出(如预期的那样)
php> include '/path/test.php';
Something
php>
Run Code Online (Sandbox Code Playgroud)
但是再次尝试相同的调用不起作用:
php> \testing\echoSome();
Not executing input: Possible call to undefined function echoSome()
See /etc/phpsh/config.sample to disable UndefinedFunctionCheck.
Run Code Online (Sandbox Code Playgroud)
没有命名空间,该功能仍然可用:
<?
function echoSome(){
echo 'Something';
}
echoSome();
Run Code Online (Sandbox Code Playgroud)
在phpsh中:
php> include '/path/test.php';
Something
Run Code Online (Sandbox Code Playgroud)
电话仍然有效:
php> echoSome();
Something
Run Code Online (Sandbox Code Playgroud)