Giter Club home page Giter Club logo

sf4_docker_example's Introduction

how to create a Symfony4 within a Docker environment:

After downloading:

  > cd Docker
  > cp .env.dist .env
  • change the APP_NAME env variable in the .env file to whatever you want your application to be called. Also, change the DB credentials and timezone if you wish.

With Makefile:

  • You can initialise the project with a tools container and a Makefile command by:
      > cd Docker
      > # create a Symfony project from symfony/skeleton
      > make init-symfony
      > # if you want to initialise with Encore, this will run the above command if the application directory doesn't exists (becasue Symfony is required)
      > make init-symfony-encore
  • start the dev containers:
      > make start
  • browse your localhost and you'll see the Symfony welcome page

From within the containers:

  • start the docker container:
    	> # note that here we are using the dev containers rather than the tools one
      > docker-compose up --build -d
  • login to the php container:
      > docker exec -it docker_php_1 bash
  • install the Symfony4 project with composer as you'd normally do (locally in the folder):
      > composer create-project symfony/skeleton .
  • If you need to initialise the Encore, you will need to use the tools container:
    	> docker-compose -f docker-compose-dev.yml up --build -d
    	> # login to the container, note that the files are mapped to /tmp
    	> docker exec -it docker_tools_1 bash
    	> # following the Guidlines on 
    	> # https://symfony.com/doc/current/frontend/encore/installation.html
    	> yarn add @symfony/webpack-encore --dev
    	> composer require encore
    	> yarn install
  • browse your localhost and you'll see the Symfony welcome page

Symfony commands from the Makefile

  • sy-require: this command will do a composer require command inside the container. Use as follows:
      > make sy-require PACK=<packname>
      > # example: make sy-require PACK=annotations
  • sy-remove: this command will do a composer remove command inside the container. Use as follows:
      > make sy-remove PACK=<packname>
      > # example: make sy-remove PACK=annotations
  • sy-run: this command will run a command on Symfony console inside the container. Use as follows:
      > make sy-run C=<symfony_command>
      > # example: make sy-run C=debug:router
  • run: this command will run a command on Symfony console inside the tools container. Use as follows:
      > make run C="<any command>"
      > # example: make run C="pwd && ls"

notes

  • it is recommended to make use of the Makefile, type make to get documentation on usage.
  • the tools container is based on php-fpm 7.1 and also has node and yarn installed globally. It also uses a non-root user tools for permissions for the composer, npm and yarn commands.
  • the tools container is only for project initialisation purposes
  • the nginx config maps to the public folder as root folder as the new SF4 now changed from web
  • php is build based on php:7.1 and added on that is the composer, pdo, xdebug and other libraries (see Docker/php/Dockerfile)

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.