如何使用symfony 5或降级版本启动本地服务器? [英] How to start local server with symfony 5 or downgrade version to 4.4?

查看:237
本文介绍了如何使用symfony 5或降级版本启动本地服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在新的Symfony 5中启动了一个新项目,但无法打开本地服务器.

在Symfony 4.4上,命令PHP bin/console server:run正常,

但是对于Symfony 5,该命令似乎未定义...

C:\Users\Chris\Code\api-test> php bin/console server:run
Command "server:run" is not defined.
Do you want to run "server:dump" instead?  (yes/no) [no]:

那么如何降级或启动本地服务器?

解决方案

Symfony 5 不包括 Web服务器捆绑包.

但是您可以简单地require将其单独安装.

例如

composer require symfony/web-server-bundle 4.4

重要的是您指定版本(4.4),因为否则它将尝试安装版本5(该版本不存在,并且将失败).

之后,您将可以像以前一样运行bin/console server:run.


如果没有,如果您已经在使用symfony可执行文件,则可以运行:

symfony server:start

此处了解更多有关Symfony服务器的信息... >


您还可以使用内置Web服务器在PHP运行时中.只需转到项目的根目录并运行:

php -S localhost:8000 -t public/

它不是功能齐全的Web服务器,但通常出于开发目的就足够了.

I started a new project in new Symfony 5 and i can't open my local server.

On Symfony 4.4 the command PHP bin/console server:run is OK,

But with Symfony 5 the command appears not to be defined...

C:\Users\Chris\Code\api-test> php bin/console server:run
Command "server:run" is not defined.
Do you want to run "server:dump" instead?  (yes/no) [no]:

So how to downgrade or start the local server?

解决方案

The Web Server Bundle is not included with Symfony 5.

But you can simply require it and install it separately.

E.g.

composer require symfony/web-server-bundle 4.4

It is important that you specify the version (4.4), because otherwise it will attempt to install version 5 (which does not exist, and it will fail).

After that you'll be able to run bin/console server:run as you used to do.


If not, if you are already using the symfony executable, you can instead run:

symfony server:start

Read more about Symfony's server here.


You can also use built-in web server in the PHP runtime. Just go to your project's root directory and run:

php -S localhost:8000 -t public/

It's not a fully featured webserver, but for developing purposes is usually enough.

这篇关于如何使用symfony 5或降级版本启动本地服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆