Setup Symfony
Setup Symfony
This example installs Symfony 7 inside the Devilbox PHP container and serves public/ through the standard Devilbox htdocs document root.
Overview
| Project name | Container path | Database | TLD_SUFFIX | Project URL |
|---|---|---|---|---|
my-symfony | /shared/httpd/my-symfony | optional | lvh.me | http://my-symfony.lvh.me / https://my-symfony.lvh.me |
Projects live in /shared/httpd/ in the PHP container and in ./data/www/ on the host.
Prerequisites
- Devilbox with PHP 8.3 or PHP 8.4 available from
env-example. - Composer available in the PHP container.
- HTTPD and Bind services.
Start the stack:
./dvl.sh up php httpd bindWalk through
It will be ready in six steps:
- Enter the PHP container.
- Create a new virtual host directory.
- Install Symfony 7.
- Link
public/tohtdocs. - Verify DNS.
- Open the project.
1. Enter the PHP container
./dvl.sh shell php832. Create the vhost directory
mkdir -p /shared/httpd/my-symfonycd /shared/httpd/my-symfony3. Install Symfony 7
Use Composer for a web application skeleton:
composer create-project symfony/skeleton:^7.0 symfonycd symfonycomposer require webappExpected structure from /shared/httpd/my-symfony:
tree -L 1.└── symfony4. Link the webroot
cd /shared/httpd/my-symfonyln -s symfony/public htdocsExpected structure:
tree -L 1.├── symfony└── htdocs -> symfony/public5. Verify DNS
my-symfony.lvh.me resolves to localhost by default. Add a hosts entry only when using a custom suffix.
6. Open your browser
Visit http://my-symfony.lvh.me or https://my-symfony.lvh.me.
Optional database setup
If your Symfony app needs MySQL, start MySQL and create a database:
./dvl.sh up mysql./dvl.sh exec "mysql -u root -h 127.0.0.1 -p -e 'CREATE DATABASE my_symfony CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'"Then set DATABASE_URL in symfony/.env.local:
Next steps
- Run Symfony console commands with
./dvl.sh exec "php bin/console"from the project directory. - Add MySQL, Redis, or Messenger transports only when the application requires them.
- Configure local HTTPS trust for browser testing.