If you run php -a
on the cmd it will become the php's interactive shell. How can I do it from a php script? For example, I can run a php script with the line exec('php -S localhost:8080');
in it to start a bult-in server and it will block the current cmd for the logs of the server. That's exactly what I want but for php -a
, to have the current cmd become the php's interactive shell but using the exec()
function does not seem to work for this.
Anyone knows how to do it? In the end it should look just a little like laravel's tinker, but not that fancy. Just want to require some files and have access to their data from the CLI.
index.php:
require 'variables.php';
exec('php -a');
then on the cmd: php index.php
(similar to laravel's artisan) and it would turn into the interactive shell so I could do something like so:
Interactive Shell
php > echo $variable_on_variables_file;
value_of_variable // outputs value of variable here on the terminal