
Symfony CLI binary allows to start a local PHP server to run your application. Many interesting options are available: local domain, HTTPS... Let's discover undocumented options or options recently documented!
Workers configuration
We can define workers, that will start automatically with the server (example taken from documentation):
# .symfony.local.yaml
workers:
# Automatically start "yarn encore" in "watch" mode
yarn_encore_watch: ~
# Automatically start "messenger:consume" with "async" transport
messenger_consume_async: ~
# You can also define your own commands
build_spa:
cmd: ['yarn', '--cwd', './spa/', 'dev']
Local wildcard domain
You probably knew that you can define local domains, for example "project.wip".
But did you know that you can also define local wildcard domains?
symfony proxy:domain:attach "*.myproject"
This way, your projet will handle eg. admin.myproject.wip, custom.myproject.wip...
Configure options using a configuration file
As you read above, the .symfony.local.yaml file allows to configure workers. But, what's not yet documented is that there are other options available!
# Sets domain1.wip and domain2.wip for the current project
proxy:
domains:
- domain1
- domain2
http:
document_root: public/ # Path to the project document root
passthru: index.php # Project passthru index
port: 8000 # Force the port that will be used to run the server
preferred_port: 8001 # Preferred HTTP port [default: 8000]
p12: path/to/p12_cert # Name of the file containing the TLS certificate to use in p12 format
allow_http: true # Prevent auto-redirection from HTTP to HTTPS
no_tls: true # Use HTTP instead of HTTPS
daemon: true # Run the server in the background
use_gzip: true # Toggle GZIP compression
Caution: if you define local domains using this configuration file, when you will run the server:start command, domains defined using the proxy:domain:attach command will be overridden.
Et voilà! :) If you have any questions, comments, suggestions... Feel free to post a comment below :)
Comments
Posted by Yahya on 21/10/2024 at 00:57.
Hello, i tried to configure my .symfony.loal.yaml file, but i have the impression that my configuration is no longer taken into account. unable to access domain1.wip or domain2.wip. "This site is inaccessible"
here is my config file
Posted by jmsche on 08/11/2024 at 17:51.
Hello Yahya,
Did you configure & start the proxy server?