Coder Social home page Coder Social logo

archtaqi / symfony-api-platform-reactjs Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 2.0 738 KB

Symfony 4 API Platform + React.js Full Stack Masterclass Cource Code

Home Page: https://udemy.com/symfony-api-platform-reactjs-full-stack-masterclass/

PHP 99.55% HTML 0.45%
symfony apiplatform

symfony-api-platform-reactjs's Introduction

Symfony API Platform

composer require maker
php bin/console make:user
composer require api
composer require jwt-auth
openssl genrsa -out config/jwt/private.pem -aes256 4096
openssl rsa -pubout -in config/jwt/private.pem -out config/jwt/public.pem

API Plateform

Features

Besides the REST and GraphQL APIs, other features include:

Native support for JSON-LD, GraphQL, JSONAPI, HAL, raw JSON, XML, YAML and CSV
Granular control over filters and sorting
Symfony-based access control for an entire resource, or a particular method
Pagination
Serialization groups: The ability to define property groups so subsets of properties can be requested instead of all properties
Advanced error handling
Doctrine extension integration for dynamically extending queries
FOSUserBundle integration
JWT Authentication (Including the ability to view Swagger UI based on a specific token)
Data Transfer Objects (DTO) for custom operations

API Resource

  • itemOperations Item operations act on an individual resource. Three default routes are defined: GET, PUT and DELETE
  • collectionOperations Collection operations act on a collection of resources. By default two routes are implemented: POST and GET.

When the ApiResource annotation is applied to an entity class, all default CRUD operations are automatically registered. Both collectionOperations and itemOperations behave independently. i.e if you don't explicitly configure operations for collectionOperations, GET and POST operations will be automatically registered, even if you explicitly configure itemOperations. The reverse is also true.

More : https://api-platform.com/docs/core/operations/

To limit what properties are accessible to either GET or POST/PUT operations, we used below;

  • normalizationContext Refers to reading properties (GET requests)
  • denormalizationContext Refers to writing data (POST/PUT requests)

In below, a user can view and update their name. They can view but not update their active status, and they have no access to what roles are assigned to them.

use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;

* @ApiResource(
*   normalizationContext={"groups"={"read"}},
*   denormalizationContext={"groups"={"write"}}
* )

    /**  @Groups({"read"})  */
    private $active;
    /**  @Groups({"read", "write"}) */
    private $name;
    private $roles;

The result of a GET request will not include the roles property. and a PUT request to will only update the name property, even if active and roles are passed along with it.

More on: https://www.thinkbean.com/drupal-development-blog/restrict-properties-api-platform-serialization-groups

symfony-api-platform-reactjs's People

Contributors

archtaqi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

b9sk valentininua

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.