Basic Debugging
Workerman has two running modes: debug mode and daemon running mode.
Running php start.php start enters debug mode, where functions such as echo, var_dump, var_export will print to the terminal. Note that when Workerman is run with php start.php start, all processes will exit when the terminal is closed.
Running php start.php start -d enters daemon mode, which is the formal production running mode, and closing the terminal will not affect it.
If you want to see the output of functions like echo, var_dump, var_export when running in daemon mode, you can set the Worker::$stdoutFile property, for example:
use Workerman\Worker;
use Workerman\Connection\TcpConnection;
require_once __DIR__ . '/vendor/autoload.php';
// Redirect screen output to the file specified by Worker::$stdoutFile
Worker::$stdoutFile = '/tmp/stdout.log';
$http_worker = new Worker("http://0.0.0.0:2345");
$http_worker->onMessage = function(TcpConnection $connection, $data)
{
$connection->send('hello world');
};
Worker::runAll();
This way, all outputs from functions such as echo, var_dump, var_export will be written to the file specified by Worker::$stdoutFile. Note that the path specified by Worker::$stdoutFile must have write permissions.