[appserver-io/appserver] Command line tool to start simple scripts
It would be helpful, to have a command line tool that enables a developer to start in a really minimal bootstrap that allows easy creation of all containers to execute a PHP script like node.js for example.
To implement a simple ServletContainer (HttpServer) instance you can implement the following script:
$server = $this->createContainer('ServletContainer', function ($req, $res) {
$res->addHeader('Status', 200);
$res->addHeader('Content-Type': 'text/plain');
$res->setContent('<p>Hello World</p>');
});
$server->listen(8586, '0.0.0.0');
after that someone can start the script directly from the commandline by typing
/opt/appserver/bin/node example.php
The script will automatically executed again if the file was edited, like the watch behavior compass has. Optional: The users system default browser will be opened if the script starts a HttpServer Container.
Good addition would be the ability to automatically detect if the command is started within a serveable environment like e.g. gulp does it.
E.g.
cd ~/myWebApp
/opt/appserver/bin/node -w
The command would automatically pick up the current directory, determine if is contains a serveable application and will start using it as webapp directory