https://github.com/garlicservices/template
Symfony 4 based Garlic Microservice template with built in necessary bundles like Bus, GraphQL, Auth etc.
https://github.com/garlicservices/template
microservice symfony template
Last synced: about 1 year ago
JSON representation
Symfony 4 based Garlic Microservice template with built in necessary bundles like Bus, GraphQL, Auth etc.
- Host: GitHub
- URL: https://github.com/garlicservices/template
- Owner: garlicservices
- License: mit
- Created: 2018-04-18T12:22:12.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-18T14:37:24.000Z (over 7 years ago)
- Last Synced: 2025-01-01T21:47:34.902Z (about 1 year ago)
- Topics: microservice, symfony, template
- Language: PHP
- Homepage:
- Size: 66.4 KB
- Stars: 1
- Watchers: 8
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Garlic service template (PHP7-FPM - MySQL)
Garlic service template application. This complete stack run with docker and [docker-compose (1.7 or higher)](https://docs.docker.com/compose/).
## Installation
1. Create a `.env` from the `.env.dist` file. Adapt it according to your symfony application
```bash
cp .env.dist .env
```
2. Build/run containers with (with and without detached mode)
```bash
$ docker-compose build
$ docker-compose up -d
```
3. Update your system host file (add template.garlic.local)
```bash
# UNIX only: get containers IP address and update host (replace IP according to your configuration)
$ docker network inspect bridge | grep Gateway
# unix only (on Windows, edit C:\Windows\System32\drivers\etc\hosts)
$ sudo echo "171.17.0.1 template.garlic.local" >> /etc/hosts
```
**Note:** For **OS X**, please take a look [here](https://docs.docker.com/docker-for-mac/networking/) and for **Windows** read [this](https://docs.docker.com/docker-for-windows/#/step-4-explore-the-application-and-run-examples) (4th step).
4. Prepare Symfony app
Composer install & create database
```bash
$ docker-compose exec php bash
$ composer install
$ sf doctrine:database:create
$ sf doctrine:schema:update --force
$ sf doctrine:fixtures:load --no-interaction
```
5. Enjoy :-)
## Usage
Just run `docker-compose up -d`, then:
* Symfony app: visit [template.garlic.local](http://template.garlic.local)
## Customize
If you want to add optionals containers like Redis, PHPMyAdmin... take a look on [doc/custom.md](doc/custom.md).
## How it works?
Have a look at the `docker-compose.yml` file, here are the `docker-compose` built images:
* `db`: This is the MySQL database container,
* `php`: This is the PHP-FPM container in which the application volume is mounted,
This results in the following running containers:
```bash
$ docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------------------------
dockersymfony_db_1 /entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp
dockersymfony_php_1 php-fpm Up 0.0.0.0:9000->9000/tcp
```
## Useful commands
```bash
# bash commands
$ docker-compose exec php bash
# Composer (e.g. composer update)
$ docker-compose exec php composer update
# SF commands (Tips: there is an alias inside php container)
$ docker-compose exec php /var/www/bin/console cache:clear # Symfony
# Same command by using alias
$ docker-compose exec php bash
$ sf cache:clear
# Retrieve an IP Address (here for the nginx container)
$ docker inspect --format '{{ .NetworkSettings.Networks.dockersymfony_default.IPAddress }}' $(docker ps -f name=nginx -q)
$ docker inspect $(docker ps -f name=nginx -q) | grep IPAddress
# MySQL commands
$ docker-compose exec db mysql -uroot -p"root"
# F***ing cache/logs folder
$ sudo chmod -R 777 var/cache var/logs # Symfony
# Check CPU consumption
$ docker stats $(docker inspect -f "{{ .Name }}" $(docker ps -q))
# Delete all containers
$ docker rm $(docker ps -aq)
# Delete all images
$ docker rmi $(docker images -q)
```
## FAQ
* Got this error: `ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.` ?
Run `docker-compose up -d` instead.
* Permission problem? See [this doc (Setting up Permission)](http://symfony.com/doc/current/book/installation.html#checking-symfony-application-configuration-and-setup)
* How to config Xdebug?
Xdebug is configured out of the box!
Just config your IDE to connect port `9001` and id key `PHPSTORM`
## Contributing
First of all, **thank you** for contributing ♥
If you find any typo/misconfiguration/... please send me a PR or open an issue. You can also ping me on [twitter](https://twitter.com/_maxpou).
Also, while creating your Pull Request on GitHub, please write a description which gives the context and/or explains why you are creating it.