My present cake project is in version 2.1.2.
I want to have a server
console command like version 3.x provides.
How do I get this working?
cd /path/to/your/app/webroot/
php -S localhost:8000
Is the equivalent of all the 3.x server command does.
Well, the cli is very simple. So all you'd need is to create a command that does the same thing, in principle:
// app/Console/Command/ServerShell.php
<?php
App::uses('AppShell', 'Console/Command');
class ServerShell extends AppShell
{
public function main()
{
$command = sprintf(
"php -S %s:%d -t %s %s",
'localhost',
8080,
escapeshellarg(WWW_ROOT),
escapeshellarg(WWW_ROOT . '/index.php')
);
system($command);
}
}
Note that this only works with version 5.4+ of php as that's when the inbuilt webserver was introduced.