$ php -S 127.0.0.1:80 -t public $ mysql.server start
$ symfony check:requirements
$ composer create-project symfony/skeleton kine_api_project
$ symfony server:start --port=80
$ cd projects/
$ git clone ...
$ cd my-project/
$ composer install
$ composer require orm-fixtures fzaninotto/faker --dev
NOTE: Souvent en phase de dev pensez à vider le cache de votre application Symfony (cela vous evitera de chercher pour des erreurs qui n'existent pas)
php bin/console cache:clear
$ php bin/console make:entity
- Creation de l'entite Patient
- Creation de l'entite Exercice (relation ManyToOne avec Patient)
NOTE: ne pas oublier de faire les migrations doctrine
$ php bin/console make:migration
$ php bin/console doctrine:migrations:migrate
$ php bin/console doctrine:fixtures:load
$ php bin/console make:user
$ php bin/console make:entity User
(ajout d'une relation OneToOne entre User et Patient)
/**
* Recupère le nombre total de repetitions à réaliser par le patient
* @Groups({"patients_read"})
* @return int
*/
public function getTotalRepetition(): int
{
return array_reduce($this->exercices->toArray(), function ($total, $exercice) {
return $total + $exercice->getNumberOf();
}, 0);
}
<?php
namespace App\Controller;
use App\Entity\Exercice;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class ExerciceIncrementationController extends AbstractController {
/**
* @var ObjectManager
*/
private $manager;
public function __construct(ObjectManager $manager)
{
$this->manager = $manager;
}
public function __invoke(Exercice $data)
{
// TODO: Implement __invoke() method.
$data->setChrono($data->getChrono() + 1);
$this->manager->flush();
return $data;
}
}
NOTE: Si erreur symfony par rapport au 'ObjectManager' ajouter Doctrine\Common\Persistence\ObjectManager: '@doctrine.orm.default_entity_manager'
au config/services.yaml
Ajout d'une operation custom au niveau de itemOperations, ici c'est l'operation 'increment' :
<?php
// App/src/entity/Exercice.php
namespace App\Entity;
use App\Repository\ExerciceRepository;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=ExerciceRepository::class)
* @ApiResource(
* attributes={
* "pagination_enabled"=true
* },
* subresourceOperations={
* "api_patients_exercices_get_subresource"={
* "normalization_context"={"groups"={"exercices_subresource"}}
* }
* },
* itemOperations={"GET","PUT","DELETE","PATCH", "increment"={
* "method"="POST",
* "path"="/exercices/{id}/increment",
* "controller"="App\Controller\ExerciceIncrementationController",
* "openapi_context"={
"summary"="Incremente un exercice",
* "description"="Incremente le chrono d'un exercice donnée"
* }
* }
* },
* normalizationContext={
* "groups"={"exercices_read"}
* }
* )
*/
https://symfony.com/doc/current/reference/constraints/NotBlank.html
composer require "lexik/jwt-authentication-bundle"
Generate keys
mkdir -p config/jwt
openssl genrsa -out config/jwt/private.pem -aes256 4096 # (1)
openssl rsa -pubout -in config/jwt/private.pem -out config/jwt/public.pem # (2)
This will ask you for the JWT_PASSPHRASE Will confirm the JWT_PASSPHRASE again
Give read rights on generated key
cd config/jwt
sudo chmod 640 private.pem
sudo chown user:www-data private.pem
Follow the jwt guide on Github LexikJWTAuth @ GitHub
$ composer req encore
$ npm install
$ npm install -D vue vue-loader vue-template-compiler
$ npm install bootstrap bootstrap-vue
$ npm install dotenv
$ npm run dev-server
$ npm run build
Historisation des données patient et 1RM inspirée de https://github.com/XSiraudin/doctrine-orm-history-bundle
docker-compose up -d --build
docker-compose exec php composer install
docker-compose exec php php bin/console doctrine:schema:create
docker-compose exec php php bin/console doctrine:fixtures:load
INSERT INTO user VALUES(null,null,'kine','["ROLE_ADMIN"]','$argon2id$v=19$m=65536,t=4,p=1$FQbKMNOe1pKdt/b7RlDk8A$egL+vKLNfTp5ocZcOAZqXLO80ntcorYZm015niwOMCc');