2017 © Pedro Peláez
 

library pipe-rat-2

Create REST APIs with just a few lines of Expressive config. This PSR7 compliant PHP library that uses Zend Expressive Middleware at its core.

image

reliv/pipe-rat-2

Create REST APIs with just a few lines of Expressive config. This PSR7 compliant PHP library that uses Zend Expressive Middleware at its core.

  • Thursday, June 28, 2018
  • by reliv
  • Repository
  • 3 Watchers
  • 0 Stars
  • 97 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 8 Versions
  • 21 % Grown

The README.md

Pipe Rat

Create REST APIs with just a few lines of Expressive config. This PSR7 compliant PHP library that uses Zend\Expressive Middleware config at its core., (*1)

  • Allows creation of API end points using only config for Doctrine entities
  • Allows configuration of common API concerns:
    • data-extractor - Getting arrays from data objects and object arrays
    • data-hydrator - Getting data from client into data objects and arrays
    • data-validate - Validating data from client
    • repository - Common repository methods
    • request-attributes - Common query params ('where', 'fields', 'limit', 'order', 'skip', etc...)
    • request-attributes-validate - Validate the params
    • request-format - Data format parsing the request data
    • response-format - Data format for response (JSON, etc...)
    • response-headers - Common headers for response (caching etc...)

Config example

'routes' => [
    /* Put your path here */
    'my.thing.find' => [
        /* Use standard route names for client simplicity */
        'name' => 'my.thing.find',

        /* Use standard route paths for client simplicity */
        'path' => 'my/thing',

        /* Wire each API independently */
        'middleware' => [
            RequestFormat::configKey()
            => RequestFormat::class,

            RequestAcl::configKey()
            => RequestAcl::class,

            RequestAttributes::configKey()
            => RequestAttributes::class,

            RequestAttributesValidate::configKey()
            => RequestAttributesValidate::class,

            /** <response-mutators> */
            ResponseHeaders::configKey()
            => ResponseHeaders::class,

            ResponseFormat::configKey()
            => ResponseFormat::class,

            ResponseDataExtractor::configKey()
            => ResponseDataExtractor::class,
            /** </response-mutators> */

            RepositoryFind::configKey()
            => RepositoryFind::class,
        ],

        /* Use route to find options at runtime */
        'options' => [
            RequestFormat::configKey() => [
                RequestFormat::OPTION_SERVICE_NAME
                => WithParsedBodyJson::class,

                RequestFormat::OPTION_SERVICE_OPTIONS => [],
            ],

            RequestAcl::configKey() => [
                RequestAcl::OPTION_SERVICE_NAME
                => IsAllowedNotConfigured::class,

                RequestAcl::OPTION_SERVICE_OPTIONS => [
                    IsAllowedNotConfigured::OPTION_MESSAGE
                    => IsAllowedNotConfigured::DEFAULT_MESSAGE
                        . ' for pipe-rat-2 resource: "{pipe-rat-2-config.resource-name}"'
                        . ' in file: "{pipe-rat-2-config.source-config-file}"',
                ],
            ],

            RequestAttributes::configKey() => [
                RequestAttributes::OPTION_SERVICE_NAMES => [
                    WithRequestAttributeFields::class
                    => WithRequestAttributeUrlEncodedFields::class,

                    WithRequestAttributeAllowedFieldConfig::class
                    => WithRequestAttributeAllowedFieldConfigFromOptions::class,

                    WithRequestAttributeExtractorFieldConfig::class
                    => WithRequestAttributeExtractorFieldConfigByRequestFields::class,

                    WithRequestAttributeWhere::class
                    => WithRequestAttributeUrlEncodedWhere::class,

                    WithRequestAttributeWhereMutator::class
                    => WithRequestAttributeWhereMutatorNoop::class,

                    WithRequestAttributeOrder::class
                    => WithRequestAttributeUrlEncodedOrder::class,

                    WithRequestAttributeSkip::class
                    => WithRequestAttributeUrlEncodedSkip::class,

                    WithRequestAttributeLimit::class
                    => WithRequestAttributeUrlEncodedLimit::class,
                ],

                RequestAttributes::OPTION_SERVICE_NAMES_OPTIONS => [
                    WithRequestAttributeAllowedFieldConfig::class => [
                        WithRequestAttributeAllowedFieldConfigFromOptions::OPTION_ALLOWED_FIELDS
                        /* @todo Over-ride with YOUR FieldsConfig */
                        => [
                            FieldConfig::KEY_TYPE => FieldConfig::COLLECTION,
                            FieldConfig::KEY_PROPERTIES => [],
                            FieldConfig::KEY_INCLUDE => true,
                        ],
                    ]
                ],
            ],

            RequestAttributesValidate::configKey() => [
                RequestAttributesValidate::OPTION_SERVICE_NAME
                => WithRequestValidAttributesAsserts::class,
            ],

            /** <response-mutators> */
            ResponseHeaders::configKey() => [
                ResponseHeaders::OPTION_SERVICE_NAME
                => WithResponseHeadersAdded::class,

                ResponseHeaders::OPTION_SERVICE_OPTIONS => [
                    WithResponseHeadersAdded::OPTION_HEADERS => []
                ],
            ],

            ResponseFormat::configKey() => [
                ResponseFormat::OPTION_SERVICE_NAME
                => WithFormattedResponseJson::class,

                ResponseFormat::OPTION_SERVICE_OPTIONS => [],
            ],

            ResponseDataExtractor::configKey() => [
                ResponseDataExtractor::OPTION_SERVICE_NAME => ExtractByType::class,
            ],
            /** </response-mutators> */

            RepositoryFind::configKey() => [
                RepositoryFind::OPTION_SERVICE_NAME
                => FindNotConfigured::class,

                RepositoryFind::OPTION_SERVICE_OPTIONS => [
                    FindNotConfigured::OPTION_MESSAGE
                    => FindNotConfigured::DEFAULT_MESSAGE
                        . ' for pipe-rat-2 resource: "{pipe-rat-2-config.resource-name}"'
                        . ' in file: "{pipe-rat-2-config.source-config-file}"',
                ],
            ],
        ],

        /* Use to define allowed methods */
        'allowed_methods' => ['GET'],
    ],
],

The Versions

28/06 2018

dev-master

9999999-dev https://github.com/reliv/pipe-rat-2

Create REST APIs with just a few lines of Expressive config. This PSR7 compliant PHP library that uses Zend Expressive Middleware at its core.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

api middleware rest zend module expressive reliv

28/06 2018

0.5.2

0.5.2.0 https://github.com/reliv/pipe-rat-2

Create REST APIs with just a few lines of Expressive config. This PSR7 compliant PHP library that uses Zend Expressive Middleware at its core.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

api middleware rest zend module expressive reliv

09/02 2018

0.5.1

0.5.1.0 https://github.com/reliv/pipe-rat-2

Create REST APIs with just a few lines of Expressive config. This PSR7 compliant PHP library that uses Zend Expressive Middleware at its core.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

api middleware rest zend module expressive reliv

09/02 2018

0.5.0

0.5.0.0 https://github.com/reliv/pipe-rat

Create REST APIs with just a few lines of Expressive config. This PSR7 compliant PHP library that uses Zend Expressive Middleware at its core.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

api middleware rest zend module expressive reliv

15/01 2018

0.2.1

0.2.1.0 https://github.com/reliv/pipe-rat

Create REST APIs with just a few lines of Expressive config. This PSR7 compliant PHP library that uses Zend Expressive Middleware at its core.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

api middleware rest zend module expressive reliv

16/10 2017

0.2.0

0.2.0.0 https://github.com/reliv/pipe-rat

Create REST APIs with just a few lines of Expressive config. This PSR7 compliant PHP library that uses Zend Expressive Middleware at its core.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

api middleware rest zend module expressive reliv

12/10 2017

0.1.1

0.1.1.0 https://github.com/reliv/pipe-rat

Create REST APIs with just a few lines of Expressive config. This PSR7 compliant PHP library that uses Zend Expressive Middleware at its core.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

api middleware rest zend module expressive reliv

10/10 2017

0.1.0

0.1.0.0 https://github.com/reliv/pipe-rat

Create REST APIs with just a few lines of Expressive config. This PSR7 compliant PHP library that uses Zend Expressive Middleware at its core.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

api middleware rest zend module expressive reliv