GithubHelp home page GithubHelp logo

api-test's Introduction

Symfony Docker

A Docker-based installer and runtime for the Symfony web framework.

Getting Started

  1. Run docker-compose up (the logs will be displayed in the current shell)
  2. Open https://localhost in your favorite web browser and accept the auto-generated TLS certificate
  3. Enjoy!

Selecting a Specific Symfony Version

Use the SYMFONY_VERSION environment variable to select a specific Symfony version.

For instance, use the following command to install Symfony 3.4:

SYMFONY_VERSION=3.4 docker-compose up --build

To install a non-stable version of Symfony, use the STABILITY environment variable during the build. The value must be a valid Composer stability option) .

For instance, use the following command to use the master branch of Symfony:

STABILITY=dev docker-compose up --build

Debugging

The default Docker stack is shipped without a Xdebug stage. It's easy though to add Xdebug to your project, for development purposes such as debugging tests or API requests remotely.

Add a Development Stage to the Dockerfile

To avoid deploying Symfony Docker to production with an active Xdebug extension, it's recommended to add a custom stage to the end of the Dockerfile.

# Dockerfile
FROM symfony_docker_php as symfony_docker_php_dev

ARG XDEBUG_VERSION=2.6.0
RUN set -eux; \
	apk add --no-cache --virtual .build-deps $PHPIZE_DEPS; \
	pecl install xdebug-$XDEBUG_VERSION; \
	docker-php-ext-enable xdebug; \
	apk del .build-deps

Configure Xdebug with Docker Compose Override

Using an override
file named docker-compose.override.yaml ensures that the production configuration remains untouched.

As example, an override could look like this:

version: '3.4'

services:
  php:
    build:
      context: .
      target: symfony_docker_php_dev
    environment:
      # See https://docs.docker.com/docker-for-mac/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host
      # See https://github.com/docker/for-linux/issues/264
      # The `remote_host` below may optionally be replaced with `remote_connect_back`
      XDEBUG_CONFIG: >-
        remote_enable=1
        remote_host=host.docker.internal
        remote_port=9001
        idekey=PHPSTORM
      # This should correspond to the server declared in PHPStorm `Preferences | Languages & Frameworks | PHP | Servers`
      # Then PHPStorm will use the corresponding path mappings
      PHP_IDE_CONFIG: serverName=symfony-docker

And run :

docker-compose -f docker-compose.yaml -f docker-compose.override.yaml up -d

Troubleshooting

Inspect the installation with the following command. The requested Xdebug version should be displayed in the output.

$ docker-compose exec php php --version

PHP 7.2.8 (cli) (built: Jul 21 2018 08:09:37) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.8, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans

Credits

Created by Kévin Dunglas and sponsored by Les-Tilleuls.coop.

api-test's People

Contributors

amenophis avatar

Watchers

 avatar  avatar  avatar

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.