How to install symfony project with docker?

by wilmer.lemke , in category: PHP Frameworks , 2 months ago

How to install symfony project with docker?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by aubrey , 2 months ago

@wilmer.lemke 

To install a Symfony project with Docker, follow these steps:

  1. Create a new Symfony project using Composer: Run the following command to create a new Symfony project with Composer: composer create-project symfony/skeleton my_project_name Replace my_project_name with the name of your Symfony project.
  2. Create a Dockerfile: Create a file named Dockerfile in the root directory of your Symfony project and add the following content: FROM php:8.0-apache RUN apt-get update && apt-get install -y zip unzip && docker-php-ext-install pdo_mysql WORKDIR /var/www/html COPY . /var/www/html CMD ["apache2-foreground"]
  3. Create a docker-compose.yml file: Create a file named docker-compose.yml in the root directory of your Symfony project and add the following content: version: '3' services: web: build: . ports: - "8000:80" volumes: - .:/var/www/html
  4. Build the Docker image: Run the following command to build the Docker image for your Symfony project: docker-compose build
  5. Start the Docker container: Run the following command to start the Docker container for your Symfony project: docker-compose up -d
  6. Access your Symfony project: You can now access your Symfony project in a web browser by navigating to http://localhost:8000.


Your Symfony project is now successfully installed and running with Docker.