Commit 6f32586a authored by Cédric Girardot's avatar Cédric Girardot

Docs : Ajoute documentation d'installation du projet en local

Change-Id: I0bebdf9da86109fb6601d282b40caa7995ffeb45
parent c9596043
......@@ -6,13 +6,10 @@ COMPOSER_VERSION=1.10
NODE_VERSION=12
XDEBUG_VERSION=2.9.4
# XDEBUG on Windows
MY_IP=127.0.0.1
SENDER_EMAIL=mon_mail@atolcd.com
SENDER_NAME=Test application notaires
# Hostname
VHOST=notaires
HTTP_HOSTNAME=notaires.docker.localhost
HTTP_PORT=80
......@@ -27,6 +24,8 @@ MYSQL_ROOT_PASSWORD=password
# Mailer
MAILER_SMTP_PORT=1025
MAILER_CLIENT_PORT=8025
SENDER_EMAIL=mon_mail@deptnot.fr
SENDER_NAME=Test application notaires
# Timezone
TIMEZONE=Europe/Paris
# Installation du projet en local pour les développeurs
## Téléchargement
[Download](https://gitlab.adullact.net/departements-notaires/departements-notaires-v2/repository/archive.zip?ref=master)
## Installation
```shell script
make install
```
## Configuration
Vérifier que les fichiers .env et appli/.env ont bien été créés et les modifier si besoin.
Dans le fichier appli_sf/.env :
* APP_ENV doit être assigné avec la valeur "dev"
* DATABASE_URL doit être définie de cette façon : mysqli://DB_USER:DB_PASSWORD@database:3306/DB_NAME\
DB_USER, DB_PASSWORD et DB_NAME sont les mêmes que dans le .env à la racine
## Accès aux services
Application web : ```http://HTTP_HOSTNAME:HTTP_PORT``` ou ```http://127.0.0.1:HTTP_PORT```
Client de messagerie : ```http://HTTP_HOSTNAME:MAILER_CLIENT_PORT```
\* HTTP_HOSTNAME, HTTP_PORT et MAILER_CLIENT_PORT sont définies dans le .env à la racine
## Commandes
Commandes Symfony :
./bin/console
Vider les caches :
./bin/console cache:clear
# Lancer les tests E2E avec Cypress
Suivre la procédure décrite [ici](HOWTO_installation_locale.md) pour l'installation du projet en local.
Les tests E2E permettent de vérifier le bon fonctionnement de l'appli. Avant de proposer une modification du code de l'appli,
il est très fortement conseillé de lancer ces tests en local (et d'en ajouter si besoin) :
......
# Symfony Docker
## Download
[Download](https://gitlab.adullact.net/departements-notaires/departements-notaires-v2/repository/archive.zip?ref=master)
## Install
make # self documented makefile
make install # build, launch, install, compile (the 5 next)
make droits # Add execution on bin files
make docker-build # build containers
make docker-start # launch containers
make composer-install # install vendors
make assets # compile assets
Set environment variables :
./bin/console cache:warmup
## Start project
make install
./bin/cc.sh
## Use
Symfony application : ```http://notaires.docker.localhost:8020``` or ```http://127.0.0.1:8020```
pgAdmin : ```http://notaires.docker.localhost:5050```
Email client : ```http://notaires.docker.localhost:8025```
## Commands
Symfony command line :
./bin/console
Generate assets :
./bin/console assets:install --symlink
make assets
Clear caches :
./bin/console cache:clear
Script to clear all caches and generate assets :
./bin/cc.sh
## Add a new server in PgAdmin
Host name/address : ```database``` (in PhpStorm, use ```localhost```)
Port : ```5432```
Database name : ```notaires```
Username : ```notaires```
Password : ```password```
## Developper tools
### Pre-commit hook with PHP Code Sniffer
Install pre-commit with ```./bin/composer copyHooks```
Now, PHP Code Sniffer analyse your code before each commit.
To remove pre-commit validations, delete file ```.git/hooks/pre-commit```
### PHP_CodeSniffer
Inspecting the PHP code to detect violations of a set of defined encoding rules.
use with : ```./bin/phpcs```
or
```./bin/composer phpcs```
### PHP-CS-Fixer
Automatically analyze and correct the PHP code to comply with coding standards (PSR-2)
use with : ```./bin/php-cs-fixer fix```
or
```./bin/composer codestyle-fix```
### PHPLint
Checking and validating the syntax of the PHP code.
use with : ```./bin/phplint```
or
```./bin/composer phplint```
### PHPStan
PHPStan focuses on finding errors in your code without actually running it.
It catches whole classes of bugs even before you write tests for the code.
It moves PHP closer to compiled languages in the sense that the correctness of each line of the code can be checked before you run the actual line.
use with : ```./bin/phpstan```
or
```./bin/composer phpstan```
### Tests
#### PHPUnit
Launches unit and functional tests.
use with : ```./bin/phpunit```
\ No newline at end of file
......@@ -12,7 +12,7 @@ include .env
# Env handle
.env: .env.dist
@if [ -f .env ]; \
@if [ -f .env ];\
then\
echo '/!\ The .env.dist file has changed. Please check your .env file (this message will not be displayed again).';\
touch .env;\
......@@ -22,6 +22,22 @@ include .env
cp .env.dist .env;\
fi
appli_sf/.env: appli_sf/.env.dist
@if [ -f appli_sf/.env ];\
then\
echo '/!\ The appli_sf/.env.dist file has changed. Please check your appli_sf/.env file (this message will not be displayed again).';\
touch appli_sf/.env;\
exit 1;\
else\
echo cp appli_sf/.env.dist appli_sf/.env;\
cp appli_sf/.env.dist appli_sf/.env;\
sed -i "/APP_ENV/s/prod/dev/" appli_sf/.env;\
sed -i "/APP_DEBUG/s/0/1/" appli_sf/.env;\
sed -i "/DATABASE_URL/s/127.0.0.1/database/" appli_sf/.env;\
sed -i "/MAILER_DSN/s/localhost:25/mail:1025/" appli_sf/.env;\
sed -i "/MAILER_SENDER/s/=/=test@depnot.test/" appli_sf/.env;\
fi
##
## Docker
......@@ -29,7 +45,7 @@ include .env
##
docker-build: ## Build stack from Dockerfile or Pull image from hub
docker-build: .env
docker-build: .env appli_sf/.env
$(DOCKER_COMPOSE) pull --ignore-pull-failures
$(DOCKER_COMPOSE) build --pull
......@@ -39,8 +55,8 @@ docker-kill:
$(DOCKER_COMPOSE) down --volumes --remove-orphans
docker-start: ## Start all docker based on docker-compose.json
docker-start: .env
@$(DOCKER_COMPOSE) up -d --remove-orphans --no-recreate
docker-start: .env appli_sf/.env
@$(DOCKER_COMPOSE) up -d --remove-orphans --no-recreate http > /dev/null
docker-stop: ## Gracefully shutdown the stack
docker-stop:
......@@ -110,7 +126,7 @@ composer-install: ./appli_sf/composer.lock
##
install: ## Install and start the project
install: .env droits docker-build docker-start wait-for-db composer-install assets
install: .env appli_sf/.env droits docker-build docker-start wait-for-db composer-install init-db assets cypress-install
update: ## Update the project
update: composer-update yarn.lock
......@@ -121,6 +137,9 @@ droits:
chmod +x appli_sf/bin/*
find . -type f -name "*.sh" -exec chmod 755 {} \;
init-db:
${BIN_DIR}console doctrine:migration:migrate --no-interaction --allow-no-migration
assets: ## Run Webpack Encore to compile assets (dev)
assets: node_modules
$(YARN) run dev
......@@ -133,7 +152,19 @@ watch: ## Run Webpack Encore in watch mode
watch: node_modules
$(YARN) run watch
.PHONY: install update droits assets assets-build watch
clean-filesystem:
rm -rf vendor appli_sf/vendor appli_sf/node_modules appli_sf/public/build appli_sf/public/media appli_sf/public/uploads
clean: ## Stop the project and remove generated files
clean: docker-kill clean-filesystem
reset: ## Stop and start a fresh install of the project
reset: clean install
cypress-install: ## Install Cypress plugins
cd appli_sf/tests/E2E/cypress && yarn && cd -
.PHONY: install update droits assets assets-build watch clean-filesystem clean reset cypress-install
node_modules: ./appli_sf/yarn.lock
......
......@@ -34,7 +34,7 @@ Mises à jour :
Pour développeurs :
* Construction des [images Docker](Documentation/Developpeur/installation_docker.md)
* Construction des [images Docker](Documentation/Developpeur/HOWTO_installation_locale.md)
* [Tests end-to-end](Documentation/Developpeur/TEST_E2E_D&N_v2.md) pour les recettes
## Changelog
......
......@@ -102,7 +102,6 @@
"phplint": "vendor/bin/phplint",
"phpstan": "vendor/bin/phpstan analyse src tests --level=5",
"codestyle-fix": "vendor/bin/php-cs-fixer fix",
"copyHooks": "cp /tmp/hooks/* /tmp/.git/hooks/ || true",
"post-install-cmd": [
"@auto-scripts"
],
......
......@@ -8,10 +8,10 @@ use App\Annotations\FileSetting;
use App\Annotations\ImageSetting;
use App\Entity\Settings;
use App\Helper\SearchHelper;
use App\Service\SettingService;
use App\Helper\UploaderHelper;
use App\Service\SettingService;
use Doctrine\Common\Annotations\AnnotationReader;
use Symfony\Component\Form\FormInterface;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
......@@ -754,12 +754,22 @@ class SettingsData
}
/**
* @param EntityManagerInterface $entityManager
*
* @return $this
* @throws \Doctrine\Common\Annotations\AnnotationException
* @throws \ReflectionException
*/
public function initFromDatabase()
public function initFromDatabase(EntityManagerInterface $entityManager)
{
// On test si la table des paramètres a bien été créée
// (évite une erreur lors d'un cache:clear avec la BD non initialisée)
$schemaManager = $entityManager->getConnection()->getSchemaManager();
$settingsTableName = $entityManager->getClassMetadata(Settings::class)->getTableName();
if ($schemaManager->tablesExist([$settingsTableName]) === false) {
return $this;
}
$reader = new AnnotationReader();
$reflect = new \ReflectionClass($this);
$objectProps = $reflect->getProperties();
......
......@@ -3,6 +3,7 @@
namespace App\Service;
use App\Data\SettingsData;
use Doctrine\ORM\EntityManagerInterface;
/**
* Class SettingService.
......@@ -18,14 +19,14 @@ class SettingsDataService
/**
* SettingDataService constructor.
*
* @param SettingsData $settingsData
* @param SettingsData $settingsData
* @param EntityManagerInterface $entityManager
*
* @throws \Doctrine\Common\Annotations\AnnotationException
* @throws \ReflectionException
*/
public function __construct(SettingsData $settingsData)
public function __construct(SettingsData $settingsData, EntityManagerInterface $entityManager)
{
$this->settingsData = $settingsData->initFromDatabase();
$this->settingsData = $settingsData->initFromDatabase($entityManager);
}
/**
......
......@@ -123,6 +123,12 @@
"imagine/imagine": {
"version": "1.2.3"
},
"laminas/laminas-code": {
"version": "3.4.1"
},
"laminas/laminas-eventmanager": {
"version": "3.2.1"
},
"laminas/laminas-zendframework-bridge": {
"version": "1.0.3"
},
......
......@@ -40,6 +40,6 @@ class SearchCivilNameControllerTest extends AbstractSearchControllerTest
$this->settingsData->setAppName('D&N');
$this->settingsData->setSearchByName(SearchHelper::SEARCH_BY_CIVIL_NAME);
$this->settingsDataService = new SettingsDataService($this->settingsData);
$this->settingsDataService = new SettingsDataService($this->settingsData, $this->entityManager);
}
}
......@@ -40,6 +40,6 @@ class SearchUseNameControllerTest extends AbstractSearchControllerTest
$this->settingsData->setAppName('D&N');
$this->settingsData->setSearchByName(SearchHelper::SEARCH_BY_USE_NAME);
$this->settingsDataService = new SettingsDataService($this->settingsData);
$this->settingsDataService = new SettingsDataService($this->settingsData, $this->entityManager);
}
}
#!/bin/bash
bin/console cache:clear
bin/console assets:install --symlink
bin/console cache:warmup
#!/bin/bash
if [[ $(make docker-php-status > /dev/null 2>&1) != 0 ]]
if ! make docker-php-status > /dev/null 2>&1;
then
make docker-start > /dev/null
fi
if [ $? != 0 ]
then
exit 1
fi
......@@ -24,6 +24,9 @@ services:
- "${HTTP_PORT:-8020}:80"
depends_on:
- php
- database
- mail
- node
volumes:
- ./docker/httpd/vhosts:/etc/apache2/sites-enabled
- ./appli_sf/:/srv/:ro
......@@ -74,12 +77,12 @@ services:
- ./appli_sf/:/srv/
e2e:
build:
context: ./docker/cypress
image: cypress/included:4.11.0
depends_on:
- http
- database
- mail
- php
environment:
TZ: ${TIMEZONE}
DISPLAY: unix$DISPLAY
......
FROM cypress/included:4.11.0
RUN npm install -g cypress-file-upload
CREATE TABLE parametrage (id INT AUTO_INCREMENT NOT NULL, cle VARCHAR(100) NOT NULL, valeur LONGTEXT DEFAULT NULL, UNIQUE INDEX UNIQ_48D9935341401D17 (cle), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB;
CREATE TABLE membre (id INT AUTO_INCREMENT NOT NULL, login VARCHAR(200) NOT NULL, password VARCHAR(255) NOT NULL, mail VARCHAR(255) NOT NULL, role LONGTEXT NOT NULL COMMENT '(DC2Type:json)', nom VARCHAR(255) NOT NULL, service VARCHAR(255) DEFAULT NULL, adresse VARCHAR(255) DEFAULT NULL, complement_adresse VARCHAR(255) DEFAULT NULL, code_postal VARCHAR(255) DEFAULT NULL, ville VARCHAR(255) DEFAULT NULL, nb_log_error INT DEFAULT 0 NOT NULL, token_reinit VARCHAR(255) DEFAULT NULL, desactive TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_F6B4FB29AA08CB10 (login), UNIQUE INDEX UNIQ_F6B4FB295126AC48 (mail), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB;
CREATE TABLE log_membre (id INT AUTO_INCREMENT NOT NULL, id_membre INT DEFAULT NULL, date DATETIME NOT NULL, echec TINYINT(1) NOT NULL, INDEX IDX_E34EA88BD0834EC4 (id_membre), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB;
CREATE TABLE instructeur (id INT AUTO_INCREMENT NOT NULL, prenom VARCHAR(255) NOT NULL, nom VARCHAR(255) NOT NULL, mail VARCHAR(255) NOT NULL, telephone VARCHAR(255) DEFAULT NULL, type_reponse LONGTEXT NOT NULL COMMENT '(DC2Type:json)', initiales LONGTEXT NOT NULL COMMENT '(DC2Type:json)', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB;
CREATE TABLE individu (id INT AUTO_INCREMENT NOT NULL, num_ind INT NOT NULL, sexe VARCHAR(1) NOT NULL, nom_usage VARCHAR(255) NOT NULL, nom_civil VARCHAR(255) DEFAULT NULL, prenom VARCHAR(255) NOT NULL, prenomd VARCHAR(255) DEFAULT NULL, prenomt VARCHAR(255) DEFAULT NULL, date_naissance DATE NOT NULL, adresse VARCHAR(255) DEFAULT NULL, mdr VARCHAR(255) DEFAULT NULL, telephone VARCHAR(255) DEFAULT NULL, mail_mdr VARCHAR(255) DEFAULT NULL, libelle VARCHAR(255) DEFAULT NULL, code_aide VARCHAR(50) DEFAULT NULL, UNIQUE INDEX UNIQ_5EE42FCE1961CB7B (num_ind), INDEX num_ind (num_ind), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB;
CREATE TABLE log_recherche (id INT AUTO_INCREMENT NOT NULL, id_membre INT DEFAULT NULL, nom VARCHAR(255) NOT NULL, prenom VARCHAR(255) NOT NULL, date_naissance DATE NOT NULL, date_deces DATE NOT NULL, lieu_deces VARCHAR(255) NOT NULL, date_acte_deces DATE NOT NULL, type_reponse INT NOT NULL, lien_pdf VARCHAR(255) NOT NULL, date_recherche DATETIME NOT NULL, id_individu INT DEFAULT NULL, INDEX IDX_A22587C8D0834EC4 (id_membre), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB;
ALTER TABLE log_membre ADD CONSTRAINT FK_E34EA88BD0834EC4 FOREIGN KEY (id_membre) REFERENCES membre (id) ON DELETE SET NULL;
ALTER TABLE log_recherche ADD CONSTRAINT FK_A22587C8D0834EC4 FOREIGN KEY (id_membre) REFERENCES membre (id) ON DELETE SET NULL;
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment