Giter VIP home page Giter VIP logo

symfony-flex-docker-compose's Introduction

A minimum-hassle docker-compose setup for developing Symfony Flex applications.

Includes

  • nginx
  • PHP 7.2
  • MySQL 5.7
  • Composer
  • ELK stack for logs (Elasticsearch, Logstash, Kibana)

Setup

  1. Copy .env.dist to .env and edit the path to your Symfony app, and the database parameters (will need to match your database parameters in your Symfony app's config)
  2. docker-compose up -d

Prerequisites

Creating a new Symfony app

You can create a new Symfony Flex app using Composer:

composer create-project symfony/skeleton app

Replace app with the path (absolute or relative) to where you'd like the app directory to be created.

Note: The composer service defined in docker-compose.yml cannot be used for creating a project, as it depends on the app path itself being mounted. The service is intended to be used for running composer commands within the context of your project. If you don't have, or don't want to have, PHP/Composer installed locally, you can still use Docker to run Composer, but in a standalone container as explained here:

docker run --rm --interactive --tty \
    --volume $PWD:/app \
    --user $(id -u):$(id -g) \
    composer create-project symfony/skeleton app

Running commands

Symfony commands can be run from the php container, e.g.

docker-compose exec php bin/console app:my_command

It will save time if you set up an alias within your shell for docker-compose exec php bin/console.

xDebug

To enable xDebug step-debugging within commands, you need to set the xdebug.remote_host PHP directive - on the command line like so:

docker-compose exec php php -dxdebug.remote_host=192.168.1.2 bin/console app:my_command

Replace 192.168.1.2 with your host machine's local network IP. I have a bash alias set up for running commands that does this automatically:

alias dcrs="docker-compose exec php php -dxdebug.remote_host=$(ip route get 192.168.1.1 | awk '{print $NF; exit}') bin/console"

Replace 192.168.1.1 with your local network's gateway, or 8.8.8.8.

Using Composer

Composer commands can be run within the composer container:

docker-compose exec composer *command*

Sometimes dependencies or Composer scripts require the availability of certain PHP extensions. You can work around this as follows:

  • Pass the --ignore-platform-reqs and --no-scripts flags

Note: The composer container runs as user 1000, the default user ID of the first non-root user created in Unix systems, so that permissions are correct on files and directories that it creates.

Logs

View logs in Kibana at http://localhost:8080

Hosts file

Add an entry to your hosts file to be able to access your app from http://symfony.test. http://localhost works too.

127.0.0.1 symfony.test

symfony-flex-docker-compose's People

Contributors

danabrey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

yaffol callistino

symfony-flex-docker-compose's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.