What Is Symfony?
Symfony is a robust PHP framework for building web applications and APIs. It provides reusable components, a powerful dependency injection container, and tools like Doctrine ORM. Deploying Symfony on your Breeze gives you a professional PHP application platform.
Prerequisites
- A Breeze running Ubuntu 22.04 or later
- PHP 8.2+ with required extensions
- Composer installed
- Nginx and MySQL/MariaDB installed
Step 1: Install PHP Extensions
sudo apt install php8.2-fpm php8.2-mysql php8.2-xml php8.2-mbstring php8.2-intl php8.2-curl php8.2-zipStep 2: Deploy the Application
cd /var/www/symfony-app
composer install --no-dev --optimize-autoloader
php bin/console doctrine:migrations:migrate --no-interaction
php bin/console cache:clear --env=prodStep 3: Set Permissions
sudo chown -R www-data:www-data var/
sudo chmod -R 775 var/Step 4: Configure Nginx
server {
listen 80;
server_name yourdomain.com;
root /var/www/symfony-app/public;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
location ~ \.php$ { return 404; }
}sudo ln -s /etc/nginx/sites-available/symfony /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginxStep 5: Environment Configuration
Create a .env.local file with your production database URL and app secret. Enable SSL with sudo certbot --nginx -d yourdomain.com.