2021-04-17 19:46:00 +00:00
|
|
|
Environnement de développement Docker pour démarrer un nouveau projet Symfony5
|
|
|
|
==================================
|
|
|
|
|
2022-10-01 15:50:16 +00:00
|
|
|
On repart de 1_docker_ready, et la procédure d'installation s'adapte comme ceci:
|
2021-04-17 19:46:00 +00:00
|
|
|
|
2022-10-01 15:50:16 +00:00
|
|
|
# Adaptations de la procédure d'installation
|
2021-04-17 19:46:00 +00:00
|
|
|
|
2022-10-01 15:50:16 +00:00
|
|
|
## 1. se mettre sur la bonne branche
|
2021-04-17 19:46:00 +00:00
|
|
|
|
2022-10-01 15:50:16 +00:00
|
|
|
```bash
|
|
|
|
$ git co -b 1_docker_ready origin/1_docker_ready
|
|
|
|
```
|
2021-04-17 19:46:00 +00:00
|
|
|
|
2022-10-01 15:50:16 +00:00
|
|
|
## 2. builder le projet
|
2021-04-17 19:46:00 +00:00
|
|
|
|
2022-10-01 15:50:16 +00:00
|
|
|
```bash
|
|
|
|
$ docker-compose build
|
|
|
|
$ docker-compose up
|
|
|
|
.. 221001_test3_db_1 exited with code 1
|
|
|
|
```
|
2021-04-17 19:46:00 +00:00
|
|
|
|
2022-10-01 15:50:16 +00:00
|
|
|
## 3. parce que 'db' ne se lance pas:
|
2021-04-17 19:46:00 +00:00
|
|
|
|
2022-10-01 15:50:16 +00:00
|
|
|
```bash
|
|
|
|
$ docker-compose rm db
|
|
|
|
$ sudo rm -rf ./data
|
|
|
|
$ docker-compose up db
|
|
|
|
```
|
2021-04-17 20:55:04 +00:00
|
|
|
|
2022-10-01 15:50:16 +00:00
|
|
|
## 4. entrer dans php
|
2021-04-17 20:55:04 +00:00
|
|
|
|
2022-10-01 15:50:16 +00:00
|
|
|
```bash
|
|
|
|
$ docker-compose exec -u 1000 php bash
|
|
|
|
```
|
2021-04-17 20:55:04 +00:00
|
|
|
|
2022-10-01 15:50:16 +00:00
|
|
|
## 5. create project
|
2021-04-17 20:55:04 +00:00
|
|
|
|
2022-10-01 15:50:16 +00:00
|
|
|
```bash
|
|
|
|
$ symfony new tadaam
|
|
|
|
$ mv tadaam/* . && mv tadaam/.* . && rmdir tadaam
|
|
|
|
```
|
2021-04-17 20:55:04 +00:00
|
|
|
|
2022-10-01 15:50:16 +00:00
|
|
|
## 6. composer require la base
|
2021-04-17 21:56:04 +00:00
|
|
|
|
2022-10-01 15:50:16 +00:00
|
|
|
```bash
|
|
|
|
$ composer require doctrine/annotations twig/twig doctrine/orm symfony/orm-pack symfony/form symfony/maker-bundle symfony/security-csrf
|
|
|
|
```
|
2021-04-17 21:56:04 +00:00
|
|
|
|
2022-10-01 15:50:16 +00:00
|
|
|
## 7. connexion postgresql
|
2021-04-17 21:56:04 +00:00
|
|
|
|
2022-10-01 15:50:16 +00:00
|
|
|
modifier DATABASE_URL dans app/.env :
|
|
|
|
```bash
|
|
|
|
+++ DATABASE_URL="postgresql://postgres:secret@db:5432/postgres?serverVersion=12&charset=utf8"
|
|
|
|
```
|
|
|
|
|
|
|
|
et dans le conteneur php :
|
|
|
|
```bash
|
|
|
|
$ bin/console doctrine:schema:create
|
|
|
|
```
|
|
|
|
|
|
|
|
## 8. composer require, la suite..
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ composer require symfony/yaml symfony/twig-bridge symfony/validator
|
|
|
|
|
|
|
|
$ composer require symfony/asset symfony/expression-language symfony/security-http symfony/translation symfony/web-link egulias/email-validator symfony/expression-language symfony/intl symfony/translation
|
|
|
|
|
|
|
|
$ composer require --dev symfony/profiler-pack symfony/debug-bundle symfony/var-dumper
|
|
|
|
```
|
|
|
|
|
|
|
|
## 9. Yarn
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ composer require symfony/webpack-encore-bundle
|
|
|
|
```
|
|
|
|
|
|
|
|
mettre en place le script qui lance docker node, le lancer pour entrer dans le conteneur node:
|
|
|
|
```bash
|
|
|
|
$ yarn install --force
|
|
|
|
$ yarn add sass sass-loader
|
|
|
|
$ yarn encore dev-server
|
|
|
|
```
|
|
|
|
|
|
|
|
## 10. c'est fait
|
|
|
|
|
|
|
|
le site est disponible sur http://localhost:8000
|