How to start local server with symfony 5 or downgrade version to 4.4?

女生的网名这么多〃 提交于 2020-01-22 00:05:08

问题


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?


回答1:


For running a local web server you can now use Symfony Client, or simply 'Symfony'.

  1. Download the binary and install it globally.

  2. Open a terminal and run once: symfony server:ca:install. This will install a local SSL certificate authority that allows you to run the local webserver on https://.

  3. Inside the terminal, move into your project directory and run symfony serve. A local webserver will start; by default on https://localhost:8000/.

If you wish to run the webserver on another port you can use symfony serve --port=8080 (in this case port 8080). For the most useful commands Symfony Client has to offer, simply run symfony. For all commands run symfony help.




回答2:


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 use symfony server:start, as shown here.




回答3:


You need to install symfony by running theses commands: cd my-project composer require symfony/web-server-bundle --dev And run the server php bin/console server:run



来源:https://stackoverflow.com/questions/59174495/how-to-start-local-server-with-symfony-5-or-downgrade-version-to-4-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!