A Symfony application needs a local HTTP entry point while controllers, templates, forms, and services are being changed. The Symfony CLI includes a development web server that starts the project from the terminal and prints the loopback URL that the browser or a smoke-test request can reach.
The local server is for development only. It listens on 127.0.0.1 by default, uses the PHP version available on the workstation, and can run in the background while editor, console, and browser checks continue against the same project.
An existing project still needs its Composer dependencies and project-specific environment values before the server can answer. A 200 response from a real route proves that the PHP front controller, routing layer, and controller response are working; a fresh skeleton without a homepage can still return 404 at / until an application route exists.
Related: How to create a Symfony project
Steps to run a Symfony project locally:
- Open the Symfony project directory.
$ cd ~/projects/acme-app
Use the directory that contains composer.json, bin/console, and the public/ document root.
- Install the project dependencies.
$ composer install Installing dependencies from lock file (including require-dev) Verifying lock file contents can be installed on current platform. Nothing to install, update or remove Generating autoload files Executing script cache:clear [OK] Executing script assets:install public [OK] Executing script importmap:install [OK]
- Confirm that the Symfony console can boot the project.
$ php bin/console about -------------------- --------------------------------- Symfony -------------------- --------------------------------- Version v8.1.0 ##### snipped ##### Environment dev Debug true ##### snipped ##### PHP -------------------- --------------------------------- Version 8.5.7 ##### snipped #####
The about command reads the same kernel that local HTTP requests will use. Fix dependency, environment, or cache errors here before starting the web server.
- Start the local web server on an explicit HTTP port.
$ symfony server:start --port=8001 --no-tls --daemon [OK] Web server listening The Web server is using PHP FPM 8.5.7 http://127.0.0.1:8001 Stream the logs via symfony server:logThe Symfony local web server is optimized for development and must not replace Nginx, Apache, or a production runtime.
- Check the local server status.
$ symfony server:status Local Web Server Listening on http://127.0.0.1:8001 The Web server is using PHP FPM 8.5.7 Local Domains Workers PID 3912: php-fpm --nodaemonize Environment Variables NoneUse another unused port if 8001 is already in use. The default Symfony port is 8000, but an explicit port keeps the smoke test URL predictable.
- Request an existing application route.
$ curl --fail --silent --show-error http://127.0.0.1:8001/healthz local symfony ok
Replace /healthz with a route that exists in the project. If no route exists yet, add a small route first, then repeat the request.
Related: How to create a Symfony route - Stop the local server when the local check is finished.
$ symfony server:stop Stopping PHP-FPM Stopping Web Server [OK] Stopped 2 process(es) successfully
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.