PHP code example of gilsegura / psr-messages

1. Go to this page and download the library: Download gilsegura/psr-messages library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gilsegura / psr-messages example snippets


   final readonly class ArticleQuery extends AbstractQuerySchema
   {
       public function __construct(
           public Page $page,
           public ArticleIncludes $     {
           return new self(
               Page::deserialize($attributes),
               ArticleIncludes::deserialize($attributes),
               ArticleFields::deserialize($attributes),
               ArticleSort::deserialize($attributes),
           );
       }
   }
   

   public function present(SerializableInterface $model, FieldsetInterface $fields, array $relationships = []): ResourceInterface
   {
       return new ResourceObject(ArticleType::ARTICLE, $model->id(), new ArticleAttributes($model->serialize()))
           ->withFieldset($fields)
           ->withOneRelationship(Article::AUTHOR, $relationships['author']);
   }