Coder Social home page Coder Social logo

env-configurator's People

Contributors

covex-nn avatar

Watchers

 avatar  avatar

env-configurator's Issues

Introduce environment configurator

Environment configurator is a Composer plugin, it was created to automate frequent routine operations. With console command, this plugin executes sequences of these operations, stored in special repositories.

To show how it works, i prepared a demo, at the end of it you will have fully functional application, running inside Docker containers, with SonataDoctrineORMAdminBundle and FOSUserBundle installed and with configured user management inside admin panel. Please, follow instructions:

  1. Configure local DNS

    Add two records to C:\WINDOWS\System32\Drivers\etc\hosts or /etc/hosts file: docker.local 127.0.0.1 and mysql 127.0.0.1. If you use Docker Toolbox and Windows as a host, execute docker-machine env, get IP-address from DOCKER_HOST variable and add that IP instead of 127.0.0.1

  2. Create a new project

    composer create-project symfony/skeleton .
  3. Install plugin, using global installation is recommended:

    composer global require covex-nn/environment

    After installation a new composer command env:apply will be available.

  4. Install SonataDoctrineORMBundle and FOSUserBundle with user management

    composer env:apply admin
  5. Configure local docker-compose environment

    composer env:apply docker-compose

    If you applied docker-compose before admin, replace host in .env file for DATABASE_URL from 127.0.0.1 to mysql manualy.

  6. Run Web-server

    Default environment uses PHP built-in Web-server

    docker-compose up -d
    php -S 127.0.0.1:80 -t public

    But if you want to use Nginx as Web server or if you do not have PHP 7.2 installed on your host, execute the following instead:

    cp docker-compose.override.yml.dist docker-compose.override.yml
    docker-compose up -d
    docker-compose exec php bin/console cache:clear
  7. Update database schema and create admin user

    php bin/console doctrine:schema:update --force
    php bin/console fos:user:create admin [email protected]
    php bin/console fos:user:promote admin ROLE_SUPER_ADMIN

    or

    docker-compose exec php bin/console doctrine:schema:update --force
    docker-compose exec php bin/console fos:user:create admin [email protected]
    docker-compose exec php bin/console fos:user:promote admin ROLE_SUPER_ADMIN

    Even if you have chosen nginx as your web-server, you can run console commands from host, it is not necessary to run them inside container. But in this case, there will be 2 var directory: first on the host and the second inside container, and with php bin/console cache:clear you will clear cache on your host, not inside VM

  8. Visit http://docker.local/admin/

Also, there is a package covex-nn/docker-symfony, it was created via composer env:apply docker-ci command. It contains same all docker files from above and some procedures for deployment with GitLab CI/CD Pipeline.

Multiple repositories

Add following to composer.json and add repository from extra.env-configurator directory:

{
    "extra": {
        "env-configurator": "src/Resources/repository"
    }
}

Add repositories from globaly installed packages, that have extra.env-configurator configuration value in composer.json

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.