How to run a Symfony project locally

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.

Steps to run a Symfony project locally:

  1. Open the Symfony project directory.
    $ cd ~/projects/acme-app

    Use the directory that contains composer.json, bin/console, and the public/ document root.

  2. 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]
  3. 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.

  4. 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:log

    The Symfony local web server is optimized for development and must not replace Nginx, Apache, or a production runtime.

  5. 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
        None

    Use 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.

  6. 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

  7. 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