我如何获得版本2.1.2的cakephp服务器命令

时间:2016-05-11 05:15:17

标签: cakephp cakephp-2.1 cakephp-3.x

我目前的蛋糕项目是2.1.2版本。 我希望有一个{3. 1}}控制台命令,如版本3.x提供。 我如何使这个工作?

2 个答案:

答案 0 :(得分:2)

不需要cli

cd /path/to/your/app/webroot/
php -S localhost:8000

相当于all the 3.x server command does

无论如何我想要一个cli

嗯,cli非常简单。所以你需要的是创建一个原则相同的命令:

// 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);        
    }
}

请注意,这仅适用于PHP版本5.4+ that's when the inbuilt webserver was introduced

答案 1 :(得分:0)

在您的文件夹中尝试以下操作:

php -S localhost:8888 -t ./app/webroot