Skip to content

aratinau/api-platform3

Repository files navigation

Api platform 3

Generated from template https://github.com/dunglas/symfony-docker

Getting Started

  1. If not already done, install Docker Compose (v2.10+)
  2. Run docker compose build --pull --no-cache to build fresh images
  3. make start
  4. make sh to enter php container
  5. php bin/console lexik:jwt:generate-keypair
  6. Open https://localhost in your favorite web browser and accept the auto-generated TLS certificate
  7. Run docker compose down --remove-orphans to stop the Docker containers.

Create and fill database

make sh (if you're not in the php container allready)

php bin/console doctrine:database:create

php bin/console doctrine:schema:update --force

Create User

POST https://localhost/api/register

{
    "email": "[email protected]",
    "password": "B2#Etw8BN3zi"
}

Authentication

POST https://localhost/api/login_check

{
    "email": "[email protected]",
    "password": "B2#Etw8BN3zi"
}

Docs

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
Loading

Example of

  • MappedSuperclass and Get Collection of EntityY and EntityZ on same GetCollection
  • Automatically applies the author with the Interface AuthorInterface.php and the Subscriber AttachAuthorSubscriber

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
Loading

PR related: #3

Format text/csv, text/dino πŸ¦•

format.png

curl -X 'GET' \
  'https://localhost/api/users?page=1' \
  -H 'accept: text/dino'

format.png

curl -X 'GET' \
  'https://localhost/api/users?page=1' \
  -H 'accept: text/csv'

format.png

PR related: #4

Notes

"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

Fix πŸ”§

  • UniqueEntity('email')
  • php bin/console hautelook:fixtures:load
  • POST https://localhost/api/entity_bs

Roadmap πŸ›£οΈ

  • 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[]
  • Install Lexik JWT

    • composer require "lexik/jwt-authentication-bundle"
    • php bin/console lexik:jwt:generate-keypair

Discussion and Message

Create a new Discussion with a Message

POST /api/discussions

{
    "content": "Fuga ducimus debitis fuga quis sint similique dolores."
}

Create a new Message to an existing Discussion

POST /api/discussions/{id}/message

{
    "content": "Hic ut et excepturi molestias amet sit."
}

TODO πŸ“

User

  • mail confirmation

  • resend mail confirmation (expiration date)

  • password forgot

  • change password forgot

  • update mail (resend confirmation mail + expiration date)

  • update password (need current password)

File

  • multipart

Misc

  • enum instead array in Book $category

MappedSuperclass

  • hydrate the results by iri
  • paginate results
  • order results
  • filter results

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published