douou9094747 2017-01-11 16:42
浏览 143

如何在Windows上使用PHP的内置Web服务器和Symfony,具有指定的主机名和非标准端口?

EDIT: Sorry everyone, this isn't something you could have fixed! The AppKernel class had been modified to change the cache directory, as below:

public function getCacheDir()
{
    if(isset($_SERVER['HTTP_HOST']))
    {
        return $this->rootDir.'/cache/'.$this->environment.'/'.$_SERVER['HTTP_HOST'];
    }
    else{
        return $this->rootDir.'/cache/'.$this->environment.'/default';
    }
 }

So not down to Symfony, or PHP, but a previous developer (presumably not on Windows!). Thanks for all your help, +1s all round.


I'm hoping there's a simple answer to this, but right now I can't see it!

Windows 10
Symfony 2.8.11
PHP 5.5.9

For convenience, I'd like to use PHP's built-in webserver (via the Symfony Console) to run a Symfony (2.8) application, on a port other than 80. I have a colleague successfully doing this, but he's using Linux, and I'm on Windows 10. The issue is that, on anything other than the standard port 80, when Symfony builds its cache the port is appended to one of the directory names, with a colon, which is illegal in Windows filenames (although not elsewhere). The cache build process fails, and the app doesn't run.

I'm starting the PHP server via Symfony's Console, like so:

php app/console server:run appname.local

The directory it's trying to build is:

C:\git\appname\app/cache/dev/appname.local:8000

And so I get the error:

RuntimeException in bootstrap.php.cache line 2763:
Unable to create the cache directory C:\git\appname\app/cache/dev/appname.local:8000)

I'd just use the standard port (this does work), but in fact I want to run several things at once, and they can't all be on 80.

Is there any way I can run a Symfony site on PHP's webserver, on Windows, on a non-standard port, in such a way that Symfony doesn't choke at the point of building the cache? For clarity, I could change webserver, and I could change OS, but for the purposes of this question assume that those are fixed. I'd prefer not to switch off the cache (it's slow enough as it is!) but that's an option if it would help.

EDIT: it seems like this works for at least some people, so there must be something different about my config. Best bet is probably the PHP version, which is quite old (not for any particular reason, just laziness).

  • 写回答

3条回答 默认 最新

  • drrkgbm6851 2017-01-11 16:50
    关注

    Symfony has a command to run a webserver (which uses the php built-in PHP server)

    php bin/console server:start
    

    This command will start the server on port 8000 (default config)

    Have a look here for more information about available options : https://symfony.com/doc/current/setup/built_in_web_server.html

    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)