I've been using phpsh for a while now, and it's worked great in the past. But its namespace support still isn't very good and this can be pretty frustrating.
Things like \Somespace\Someclass::someStaticFunction()
don't work without disabling the check whether or not a method exists, which leads to frequent fatal errors on typos that reset your environment.
There are multiple PHP REPLs out there, including the PHP built-in shell (php -a
), which is horrible to use.
Does anyone know of an alternative or perhaps a phpsh-fork with proper namespace support? Or perhaps an easy configuration fix I've overlooked...
an example:
This testfile:
<?
namespace testing;
function echoSome(){
echo 'Something';
}
\testing\echoSome();
produces this output in phpsh (as expected)
php> include '/path/test.php';
Something
php>
But trying the same call again does not work:
php> \testing\echoSome();
Not executing input: Possible call to undefined function echoSome()
See /etc/phpsh/config.sample to disable UndefinedFunctionCheck.
without namespaces the function is still available:
<?
function echoSome(){
echo 'Something';
}
echoSome();
in phpsh:
php> include '/path/test.php';
Something
and the call still works:
php> echoSome();
Something
I found that using eval worked as a good workaround:
php> = eval('return \testing\echoSome();')
Yea, it's a hack but a handy one. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With