Giter Site home page Giter Site logo

php-docker-app's Introduction

php-docker-app

This project intends to provide various php docker configurations as templates for new projects.

Feel free to comment, test, fix, contribute or add your own template.

Branches

  • master - providing php, nginx and mysql + symfony skeleton & Doctrine
  • php-nginx - basic php and nginx setup
  • php-nginx-mysql - basic php, nginx and mysql setup
  • php-nginx-composer - basic php and nginx setup + composer
  • php-nginx-mysql-composer - basic php, nginx and mysql setup + composer
  • php-nginx-symfony - basic php and nginx setup + symfony skeleton
  • php-nginx-mysql-symfony - basic php, nginx and mysql + symfony skeleton & Doctrine

docker-compose

The simplest way to start the webserver and php-fpm containers is to use docker-compose by running:

jdoe@host:/home/jdoe/projects/app $ docker-compose up -d

Run cron-jobs or any other command by starting a new container:

jdoe@host:/home/jdoe/projects/app $ docker-compose run [--rm] app php --version
PHP 7.3.9 (cli) (built: Sep 12 2019 10:23:43) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans 

Hook into running container to run your php software inside its environment:

jdoe@host:/home/jdoe/projects/app $ docker-compose exec app bash -l
root@app:/var/www/app# php --version
PHP 7.3.9 (cli) (built: Sep 12 2019 10:23:43) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans 

The same for a fresh container instance:

jdoe@host:/home/jdoe/projects/app $ docker-compose run --rm app bash -l
root@app:/var/www/app# php --version
PHP 7.3.9 (cli) (built: Sep 12 2019 10:23:43) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans 

development and production stages

The docker image has two stages for development and production. This way development can take place inside the same environment. For the development stage, debugging settings are enabled.

docker-compose.yml & docker-compose.override.yml

The basic docker-compose.yml is intended to be extended by overrides and is therefore very minimal (no port mappings e.g.). Extend it by adding your customized override file. Templates are provided for development and production. The development override mounts the project directory from the host machine to enable rapid development inside the container.

composer (php)

The latest master version of composer (https://getcomposer.org) is installed. Use it from a running container to manage your app:

jdoe@host:/home/jdoe/projects/app $ docker-compose exec app bash -l
root@app:/var/www/app# composer --version
Composer version 1.9.0 2019-08-02 20:55:32

... or run it inside a fresh container, if you prefer:

jdoe@host:/home/jdoe/projects/app $ docker-compose run --rm app bash -l
root@app:/var/www/app# composer --version
Composer version 1.9.0 2019-08-02 20:55:32

symfony 4.3

The symfony 4.3 skelleton, as well as the symfony installer is part of the project. Use the skeleton or remove it and use the symfony command to create a new project.

jdoe@host:/home/jdoe/projects/app $ docker-compose run --rm app bash -l
root@app:/var/www/app# symfony new myapp
...

Use the symfony console from running container:

jdoe@host:/home/jdoe/projects/app $ docker-compose exec app bash -l
root@app:/var/www/app# bin/console cache:clear
...

php-docker-app's People

Contributors

t11n avatar

Watchers

James Cloos 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.