问题
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'.
Download the binary and install it globally.
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 onhttps://
.- Inside the terminal, move into your project directory and run
symfony serve
. A local webserver will start; by default onhttps://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