make build
make up
make sh
(if you're not in the php container allready)
php bin/console doctrine:database:create
php bin/console doctrine:schema:update --force
php bin/console doctrine:fixtures:load -n
POST https://localhost/api/register
{
"email": "[email protected]",
"password": "B2#Etw8BN3zi"
}
POST https://localhost/api/login_check
{
"email": "[email protected]",
"password": "B2#Etw8BN3zi"
}
Summary of Association Override, Attribute Override, Mapped Superclasses
EntityA EntityB Example using InheritanceType
in mode SINGLE_TABLE
PR related: #1
EntityX EntityY EntityZ Example using MappedSuperclass
on abstract class
classDiagram
EntityX --> EntityY
EntityX --> EntityZ
class EntityX ~abstract~
EntityX : +User author
EntityX : +string name
class EntityY
EntityY : +string recipient
class EntityZ
EntityZ : +Collection recipients
Example of
MappedSuperclass
and Get Collection of EntityY and EntityZ on same GetCollection- Automatically applies the author with the Interface
AuthorInterface.php
and the SubscriberAttachAuthorSubscriber
PR related: #2
Mail MailIncoming MailOutcoming of 🚀 InheritanceType
in mode JOINED
classDiagram
Mail --> MailIncoming
Mail --> MailOutcoming
class Mail
Mail : +User author
Mail : +string subject
class MailIncoming
MailIncoming : +string sender
MailIncoming : +Collection recipients
class MailOutcoming
MailOutcoming : +User sender
MailOutcoming : +string recipient
PR related: #3
curl -X 'GET' \
'https://localhost/api/users?page=1' \
-H 'accept: text/dino'
curl -X 'GET' \
'https://localhost/api/users?page=1' \
-H 'accept: text/csv'
PR related: #4
"hydra:description": "Unable to generate an IRI for the item of type \"App\\Entity\\EntityB\""
This was happening because the entity was never being saved, so the id was never generated.
https://stackoverflow.com/questions/57887026/unable-to-generate-an-iri-for-the-item-of-type-exception-after-api-platform-mi
UniqueEntity('email')
php bin/console hautelook:fixtures:load
POST https://localhost/api/entity_bs
- fork from dunglas/symfony-docker
- install doctrine, api-platform, fixtures
composer require symfony/orm-pack
composer require --dev symfony/maker-bundle
-
Creation Book entity + fixtures
- filter on
category[]
- filter on
-
Install Lexik JWT
composer require "lexik/jwt-authentication-bundle"
php bin/console lexik:jwt:generate-keypair
je créé une discussion
- j'informe les autres qu'il y a une discussion
je créé un message :
- j'informe les autres qu'il y a un message
je lis un message :
- je mets a read discussion
- je mets a read message
On créé un message avec DiscussionPostProcessor.php
et le payload suivant
{
"content": "{{$randomLoremSentences}}",
"participants": [
"/api/users/17325",
"/api/users/17327"
]
}
- On créé une discussion, avec DiscussionPostProcessor.php
- Les participants lisent avec ReadMessageNotificationListener.php
- On créé un message avec CreateMessageNotificationListener.php
Amélioration : supprimer MessageNotification une fois lue ?
POST /api/discussions
{
"content": "Fuga ducimus debitis fuga quis sint similique dolores."
}
POST /api/discussions/{id}/message
{
"content": "Hic ut et excepturi molestias amet sit."
}
Enables you to monitor changes to an entity attribute, so that you can launch an event when the change is made.
#[ORM\Column(length: 255)]
#[WatchProperty(
events: [\Doctrine\ORM\Events::postPersist],
triggerEventName: 'custom.event.name'
)]
#[Groups(groups: ['todo:read', 'todo:write'])]
private ?string $title = null;
with
<?php
namespace App\DoctrineListener;
use App\Attribute\WatchProperty;
use App\Entity\Todo;
use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Doctrine\ORM\Events;
use ReflectionClass;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
#[AsDoctrineListener(Events::preUpdate/*, 500, 'default'*/)]
class WatchPropertyPreUpdateListener
{
public function __construct(
private EventDispatcherInterface $eventDispatcher
) {
}
public function preUpdate(PreUpdateEventArgs $args): void
{
$entity = $args->getObject();
if (!$entity instanceof Todo) {
return;
}
$reflectionClass = new ReflectionClass($entity);
foreach ($reflectionClass->getProperties() as $property) {
$attributes = $property->getAttributes(WatchProperty::class);
foreach ($attributes as $attribute) {
/** @var WatchProperty $instance */
$instance = $attribute->newInstance();
$newValue = $property->getValue($entity);
$oldValue = $args->getOldValue($property->getName());
if ($triggerEventName = $instance->triggerEventName) {
$event = new \App\Event\CustomEvent(
message: sprintf('Custom event triggered for %s::%s', get_class($entity), $property->getName()),
data: [
'entity' => $entity,
'property' => $property->getName(),
'newValue' => $newValue,
'oldValue' => $oldValue
]
);
$this->eventDispatcher->dispatch($event, $triggerEventName);
}
}
}
}
}
will launch the following event:
<?php
namespace App\EventSubscriber;
use App\Event\CustomEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class CustomEventSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
'custom.event.name' => 'onCustomEvent',
];
}
public function onCustomEvent(CustomEvent $event): void
{
// Logique personnalisée
dump('Custom event received: ' . $event->getMessage());
dump($event->getData());
dd('toto');
}
}
-
mail confirmation
-
resend mail confirmation (expiration date)
-
password forgot
-
change password forgot
-
update mail (resend confirmation mail + expiration date)
-
update password (need current password)
- multipart
- enum instead array in Book $category
- hydrate the results by iri
- paginate results
- order results
- filter results