PHP REST API Framework

Related tags

API api php framework rest
Overview

PSX Framework

About

PSX is a framework written in PHP dedicated to build REST APIs. It is based on multiple components which cover many aspects of the API lifecycle. These components are independent of the framework and can also be used in another context. The following list contains the most notable packages:

  • psx/api Parse and generate API specification formats (i.e. OpenAPI, RAML)
  • psx/data Data processing library to read and write POPOs in different formats
  • psx/schema Parse and generate data schema formats (i.e. JsonSchema)
  • psx/sql Build complex data structures from relational databases
  • psx/framework Engine of the PSX framework

More informations about the PSX framework and the components at phpsx.org.

Requirements

>= PHP 7.0

Installation

To install the full stack framework you can install the sample project which creates a basic PSX project with a sample API.

php composer.phar create-project psx/sample .

you can also download the current release from GitHub which already includes all vendor libraries in case you can not use composer

https://github.com/apioo/psx/releases

Documentation

For documentation please take a look at phpsx.org or the official manual

Build Status

Comments
  • Improve oauth2 support

    Improve oauth2 support

    Oauth2 support is currently available but not fully tested and documented. We need to improve the test cases and code coverage. Also we must provide a chapter in the manual howto enable oauth authentication for an API endpoint.

    opened by chriskapp 4
  • Issue opening sample app in swagger

    Issue opening sample app in swagger

    When I hit 127.0.0.1:8080/tool/swagger I get

    { success: false, title: "PSX\Http\Exception\NotFoundException", message: "Invalid resource in /Applications/MAMP/htdocs/test/vendor/psx/framework/src/Controller/Generator/SwaggerController.php on line 69", trace: "#0 /Applications/MAMP/htdocs/test/vendor/psx/framework/src/Filter/ControllerExecutor.php(52): PSX\Framework\Controller\Generator\SwaggerController->onGet() #1 /Applications/MAMP/htdocs/test/vendor/psx/framework/src/Filter/FilterChain.php(79): PSX\Framework\Filter\ControllerExecutor->handle(Object(PSX\Http\Request), Object(PSX\Http\Response), Object(PSX\Framework\Filter\FilterChain)) #2 /Applications/MAMP/htdocs/test/vendor/psx/framework/src/Loader/Loader.php(158): PSX\Framework\Filter\FilterChain->handle(Object(PSX\Http\Request), Object(PSX\Http\Response)) #3 /Applications/MAMP/htdocs/test/vendor/psx/framework/src/Loader/Loader.php(126): PSX\Framework\Loader\Loader->executeController(Object(PSX\Framework\Controller\Generator\SwaggerController), Object(PSX\Http\Request), Object(PSX\Http\Response)) #4 /Applications/MAMP/htdocs/test/vendor/psx/framework/src/Dispatch/Dispatch.php(121): PSX\Framework\Loader\Loader->load(Object(PSX\Http\Request), Object(PSX\Http\Response), Object(PSX\Framework\Loader\Context)) #5 /Applications/MAMP/htdocs/test/public/index.php(33): PSX\Framework\Dispatch\Dispatch->route(Object(PSX\Http\Request), Object(PSX\Http\Response)) #6 /Applications/MAMP/htdocs/test/public/server.php(35): require_once('/Applications/M...') #7 {main}", context: "65 66 $this->setHeader('Content-Type', 'application/json'); 67 $this->setBody($swagger); 68 } else { 69 throw new HttpException\NotFoundException('Invalid resource'); 70 } 71 } 72 } " }

    opened by ryan-wong 2
  • No Endpoints in psx sample project

    No Endpoints in psx sample project

    I'm following the instructions here: http://phpsx.org/get-started

    I can get the /documentation but the root / and api /population return errors.

    {
        "success": false,
        "title": "ReflectionException",
        "message": "Class Sample\\Api\\Index does not exist in \/home\/vagrant\/code\/x\/psx\/vendor\/psx\/framework\/src\/Dependency\/ObjectBuilder.php on line 70",
        "trace": "#0 \/home\/vagrant\/code\/x\/psx\/vendor\/psx\/framework\/src\/Dependency\/ObjectBuilder.php(70): ReflectionClass->__construct('Sample\\\\Api\\\\Inde...')\n#1 \/home\/vagrant\/code\/x\/psx\/vendor\/psx\/framework\/src\/Dispatch\/ApplicationStackFactory.php(47): PSX\\Framework\\Dependency\\ObjectBuilder->getObject('Sample\\\\Api\\\\Inde...', Array, 'PSX\\\\Framework\\\\A...')\n#2 \/home\/vagrant\/code\/x\/psx\/vendor\/psx\/framework\/src\/Loader\/CallbackResolver\/DependencyInjector.php(59): PSX\\Framework\\Dispatch\\ApplicationStackFactory->getController('Sample\\\\Api\\\\Inde...', Object(PSX\\Http\\Request), Object(PSX\\Http\\Response), Object(PSX\\Framework\\Loader\\Context))\n#3 \/home\/vagrant\/code\/x\/psx\/vendor\/psx\/framework\/src\/Loader\/Loader.php(115): PSX\\Framework\\Loader\\CallbackResolver\\DependencyInjector->resolve(Object(PSX\\Http\\Request), Object(PSX\\Http\\Response), Object(PSX\\Framework\\Loader\\Context))\n#4 \/home\/vagrant\/code\/x\/psx\/vendor\/psx\/framework\/src\/Dispatch\/Dispatch.php(121): PSX\\Framework\\Loader\\Loader->load(Object(PSX\\Http\\Request), Object(PSX\\Http\\Response), Object(PSX\\Framework\\Loader\\Context))\n#5 \/home\/vagrant\/code\/x\/psx\/vendor\/psx\/framework\/src\/Environment\/WebServer\/Engine.php(47): PSX\\Framework\\Dispatch\\Dispatch->route(Object(PSX\\Http\\Request), Object(PSX\\Http\\Response))\n#6 \/home\/vagrant\/code\/x\/psx\/vendor\/psx\/framework\/src\/Environment\/Environment.php(67): PSX\\Framework\\Environment\\WebServer\\Engine->serve(Object(PSX\\Framework\\Dispatch\\Dispatch), Object(PSX\\Framework\\Config\\Config))\n#7 \/home\/vagrant\/code\/x\/psx\/public\/index.php(28): PSX\\Framework\\Environment\\Environment->serve()\n#8 \/home\/vagrant\/code\/x\/psx\/public\/server.php(35): require_once('\/home\/vagrant\/c...')\n#9 {main}",
        "context": "66      }\n67  \n68      public function getObject($className, array $constructorArguments = array(), $instanceOf = null)\n69      {\n<b>70          $class = new ReflectionClass($className);\n<\/b>71  \n72          if ($class-&gt;getConstructor() === null) {\n73              $object = $class-&gt;newInstanceArgs([]);\n74          } else {\n"
    }
    
    {
        "success": false,
        "title": "ReflectionException",
        "message": "Class Sample\\Api\\Population\\Collection does not exist in \/home\/vagrant\/code\/x\/psx\/vendor\/psx\/framework\/src\/Dependency\/ObjectBuilder.php on line 70",
        "trace": "#0 \/home\/vagrant\/code\/x\/psx\/vendor\/psx\/framework\/src\/Dependency\/ObjectBuilder.php(70): ReflectionClass->__construct('Sample\\\\Api\\\\Popu...')\n#1 \/home\/vagrant\/code\/x\/psx\/vendor\/psx\/framework\/src\/Dispatch\/ApplicationStackFactory.php(47): PSX\\Framework\\Dependency\\ObjectBuilder->getObject('Sample\\\\Api\\\\Popu...', Array, 'PSX\\\\Framework\\\\A...')\n#2 \/home\/vagrant\/code\/x\/psx\/vendor\/psx\/framework\/src\/Loader\/CallbackResolver\/DependencyInjector.php(59): PSX\\Framework\\Dispatch\\ApplicationStackFactory->getController('Sample\\\\Api\\\\Popu...', Object(PSX\\Http\\Request), Object(PSX\\Http\\Response), Object(PSX\\Framework\\Loader\\Context))\n#3 \/home\/vagrant\/code\/x\/psx\/vendor\/psx\/framework\/src\/Loader\/Loader.php(115): PSX\\Framework\\Loader\\CallbackResolver\\DependencyInjector->resolve(Object(PSX\\Http\\Request), Object(PSX\\Http\\Response), Object(PSX\\Framework\\Loader\\Context))\n#4 \/home\/vagrant\/code\/x\/psx\/vendor\/psx\/framework\/src\/Dispatch\/Dispatch.php(121): PSX\\Framework\\Loader\\Loader->load(Object(PSX\\Http\\Request), Object(PSX\\Http\\Response), Object(PSX\\Framework\\Loader\\Context))\n#5 \/home\/vagrant\/code\/x\/psx\/vendor\/psx\/framework\/src\/Environment\/WebServer\/Engine.php(47): PSX\\Framework\\Dispatch\\Dispatch->route(Object(PSX\\Http\\Request), Object(PSX\\Http\\Response))\n#6 \/home\/vagrant\/code\/x\/psx\/vendor\/psx\/framework\/src\/Environment\/Environment.php(67): PSX\\Framework\\Environment\\WebServer\\Engine->serve(Object(PSX\\Framework\\Dispatch\\Dispatch), Object(PSX\\Framework\\Config\\Config))\n#7 \/home\/vagrant\/code\/x\/psx\/public\/index.php(28): PSX\\Framework\\Environment\\Environment->serve()\n#8 \/home\/vagrant\/code\/x\/psx\/public\/server.php(35): require_once('\/home\/vagrant\/c...')\n#9 {main}",
        "context": "66      }\n67  \n68      public function getObject($className, array $constructorArguments = array(), $instanceOf = null)\n69      {\n<b>70          $class = new ReflectionClass($className);\n<\/b>71  \n72          if ($class-&gt;getConstructor() === null) {\n73              $object = $class-&gt;newInstanceArgs([]);\n74          } else {\n"
    }
    
    opened by thinsoldier 1
  • Add Swagger 2.0 support

    Add Swagger 2.0 support

    Currently we generate Swagger 1.2 specification. Since 2.0 is becoming the standard we also need support for this spec. This includes roughly the following tasks;

    • Add a new Swagger2 model to the psx/model component
    • Add a Swagger2 generator to the psx/api component
    opened by chriskapp 1
  • Dynamic schema types

    Dynamic schema types

    It would be great to have a way to specify dynamic types inside a model. I.e. we have a model class like this:

    class Collection
    {
        /**
         * @Type("array<?>")
         */
        protected $entry;
    }
    

    In our controller we can then use this model to specify the dynamic type i.e.:

    @Outgoing(code=200, schema="Collection<Sample\Model\Population>")

    Then we could use the same collection with different classes. This would greatly increase the reusability of such models so we dont need to create a collection model for every type.

    opened by chriskapp 1
  • Use react json inspector as HTML view

    Use react json inspector as HTML view

    At the moment the HTML representation of the data is a simple <dl> with some CSS styling. We could use a more fancy JSON viewer i.e.: https://github.com/Lapple/react-json-inspector

    opened by chriskapp 1
  • Parameters for redirect route

    Parameters for redirect route

    If we have a redirect route i.e. ~/api/posts the ?format=json parameter does not work. Probably the parameters are not correctly redirected to the destination route.

    opened by chriskapp 1
  • Implement JSONRpc proxy controller

    Implement JSONRpc proxy controller

    It would be possible to create a JSONRpc (http://www.jsonrpc.org/specification) proxy controller which receives JSONRpc calls and redirects them to the appropriated controller and returns the reponse.

    opened by chriskapp 1
  • Option to add global middlewares

    Option to add global middlewares

    It should be possible to configure global middlewares in the configuration which are applied for every controller. Probably we should have a "pre" and "post" option so pre middlewares are applied before the controller is called and post after the controller was called.

    opened by chriskapp 1
  • Add option to add a custom validator to the schema visitor

    Add option to add a custom validator to the schema visitor

    At the moment we can validate incoming data in the scope of the JsonSchema spec. It should be possible to add a custom validator to the schema visitor so that we can add more complex validation rules i.e. check whether a value exists in a table. It should be possible to attach a validator object to the schema visitor. The validator applies then all validation rules.

    opened by chriskapp 1
  • Data schema add support for different types

    Data schema add support for different types

    At the moment it is not possible to define an value which contains different types. It is only possible to set one specific type. This could be implemented by JsonSchema with "oneOf" and by XSD with "xsd:choice".

    opened by chriskapp 1
Releases(v6.0.0)
  • v6.0.0(Dec 28, 2021)

    • Migrated to PHP 8.0
    • Removed deprecated classes and methods
    • Moved from doctrine annotations to PHP attributes
    • Updated all components to PHP 8.0
    • Move logic of the SchemaApiAbstract into the ControllerAbstract class
    Source code(tar.gz)
    Source code(zip)
  • v4.0.0(Dec 31, 2017)

  • v3.0.3(Dec 31, 2017)

  • v3.0.2(Aug 9, 2017)

  • v3.0.1(Aug 9, 2017)

  • v3.0.0(Dec 24, 2016)

  • v2.0.1(Sep 11, 2016)

  • v2.0.0(May 8, 2016)

    • Split the framework into components
    • Decoupled and improved each component
    • Reading and writing data works now with POPOs
    • Add generator to generate PHP classes from a RAML and JsonSchema specification
    • Removed command system
    • Improved documentation
    Source code(tar.gz)
    Source code(zip)
    psx_2.0.0.zip(5.35 MB)
  • v2.0.0-RC1(Apr 30, 2016)

  • v1.2.3(Feb 17, 2016)

  • v1.2.2(Feb 8, 2016)

  • v1.2.1(Feb 7, 2016)

    • Add pseudo ANY request method to the routing parser
    • Removed annotation loader
    • Dispatcher add option to disable sending the response to the client
    • Add SoapProxyController which handles all SOAP communication
    • Add option to restrict fields at the table abstract class
    Source code(tar.gz)
    Source code(zip)
    psx_1.2.1.zip(4.38 MB)
  • v1.2.0(Jan 24, 2016)

    • Add annotation API controller which can be used to specify the API behaviour through annotations
    • Improved api generation command
    • Add doctrine annotation reader for annotation parsing
    • Unify doctrine cache usage and improve entity manager integration
    • Oauth2 token endpoint handle also client_id and client_secret parameter
    Source code(tar.gz)
    Source code(zip)
    psx_1.2.0.zip(4.37 MB)
  • v1.1.4(Dec 29, 2015)

    • The schema API handles now automatically HEAD requests
    • Add support for PATCH request method
    • Fix automatic template detection for psr4 namespaces
    • Renamed doCreate and doUpdate method to doPost and doPut to follow the http request method naming scheme
    • Json schema document throw an exception if a json pointer could not be resolved
    Source code(tar.gz)
    Source code(zip)
    psx_1.1.4.zip(4.26 MB)
  • v1.1.3(Dec 27, 2015)

  • v1.1.2(Dec 27, 2015)

    • Add option to specify global middlewares
    • Updated composer dependencies
    • Graph traverser handle also objects which implement JsonSerializable, ArrayObject or Traversable
    • JsonSchema parser set default id if not available
    • Improve dispatcher dont send the response for nested calls
    • Fixed comperator record comparsion and add test case
    Source code(tar.gz)
    Source code(zip)
    psx_1.1.2.zip(4.26 MB)
  • v1.1.1(Nov 21, 2015)

    • Add logger configuration settings and factory
    • Add json patch and pointer implementation. The accessor uses now also the json pointer syntax
    • Add record serializer and add transformer which builds a record graph from arbitrary data
    • Add option to attach a validator to the importer inside a controller
    • Make ImporterManager immutable so that it is not possible to globally change a importer object
    • Improved validator
    • Renamed some classes for PHP7 compatibility
    • Removed class PSX\Data\Object and added static factory method fromArray to PSX\Data\Record
    • Adjust visitor exception messages
    Source code(tar.gz)
    Source code(zip)
    psx_1.1.1.zip(4.24 MB)
  • v1.1.0(Oct 5, 2015)

    • Curve array nest method handle indexed arrays
    • JSON Schema add title property to complex types
    • Documentation controller returns also the API endpoint url
    • XML generator validate element names
    • Documentation controller returns now the complete json schema which can be used by the API client to generate a documentation
    • Improved swagger and json schema generator
    • Extended api resource methods
    Source code(tar.gz)
    Source code(zip)
    psx_1.1.0.zip(4.78 MB)
  • v1.0.7(Aug 22, 2015)

  • v1.0.6(Aug 3, 2015)

    • Fix schema parse read description of array and scalar types
    • Add any schema property type
    • Messages of StatusCodeException are now shown to the user when in production mode
    • Add title and required parameter to accessor
    • Set controllerClass variable for template writers
    Source code(tar.gz)
    Source code(zip)
    psx_1.0.6.zip(4.75 MB)
  • v1.0.5(Jul 22, 2015)

  • v1.0.4(Jul 5, 2015)

    • Switched to PSR-2 coding style and using absolute class paths in phpdocs
    • Improve controller test cases
    • Add RecordInterface access to Accessor
    • Add JsonSerializable interface to record abstract
    • For incoming requests an exception is now throw if the data structure contains keys which are not available in the schema
    • Add development status for an API resource
    Source code(tar.gz)
    Source code(zip)
    psx_1.0.4.zip(4.74 MB)
  • v1.0.3(Jun 13, 2015)

    • Added new ChoiceType property which allows different kinds of objects as value
    • Use same logic for traversing incoming and outgoing data
    • Moved schema property methods assimilate and validate into seperate class
    • Improved record factory factory class which uses now the object build to get arbitrary dependencies
    • Implemented factory to convert requests into PSR-7 objects and vice versa
    • Improved many test cases
    Source code(tar.gz)
    Source code(zip)
    psx_1.0.3.zip(4.76 MB)
  • v1.0.2(May 23, 2015)

  • v1.0.1(May 22, 2015)

    • Added raml file parameter for api generation command
    • Improved raml parser and tests
    • Add format key to swagger parameter record
    • Add iterator and countable interface to complex type
    • Improved raml and swagger generation
    • Add return $this to MethodAbstract::setDescription
    • Add debug commands to print an raml and jsonschema resource definition
    • Add console commands to generate different schema representations of the api
    Source code(tar.gz)
    Source code(zip)
    psx_1.0.1.zip(4.70 MB)
  • v1.0.0(May 2, 2015)

    • Removed unused methods in documentation controller
    • Added property type factory class
    • Gain php7 compatibility
    • Json schema parser add schema version check
    • Improved schema data, validation and api controller test cases
    • Fixed datetime wrong behaviour without constructor args
    Source code(tar.gz)
    Source code(zip)
    psx_1.0.0.zip(4.67 MB)
  • v1.0.0-RC2(Apr 28, 2015)

    • Fixed correct handling with date and time formats
    • Improved several value objects
    • Improved controller schema api tests
    • Pass controller context when forwarding an request to another controller
    • The name of the exception record is now "error"
    • Add a new context value so that all controllers share the same supported writer value
    • Moved body trait methods into the controller abstract class
    • Added controller set stdClass body test
    • Improved XSD generator and allow setting min max array length
    Source code(tar.gz)
    Source code(zip)
    psx_1.0.0-RC2.zip(4.65 MB)
  • v1.0.0-RC1(Apr 22, 2015)

  • v0.9.10(Apr 17, 2015)

    • Added getConnection method to table manager to enable easy transaction handling
    • Moved cache logic from table manager into seperate reader class
    • Added exception converter service which converts an exception into an record which gets used to display error messages. This makes it easy to change the global error response format
    • Send correct content type on exception or send 415 status code
    • Handle Accept headers with +json or +xml media types correctly
    • Added jsonx format to default api controller
    • Added http StreamInterface and remove psr http dependency
    • Updated bootstrap cache generator file list
    • Resource listing controller documentation create context in seperate method which can be overloaded
    Source code(tar.gz)
    Source code(zip)
    psx_0.9.10.zip(4.63 MB)
  • v0.9.9(Apr 5, 2015)

    • Handle different successful status codes in schema api
    • Updated manual
    • Removed html presentations from tool controllers
    • Fixed xml writer nested array definitions
    • Removed rest client controller since it contains no logic
    • Improved raml parser
    • Improved json schema parse resolve external resources. Supports file:// and http:// protocol
    Source code(tar.gz)
    Source code(zip)
    psx_0.9.9.zip(4.62 MB)
A simple, extensible REST API framework for PHP

Note: This framework is not stable yet. Introduction Aphiria is a suite of small, decoupled PHP libraries that make up a REST API framework. It simpli

Aphiria 119 Dec 23, 2022
Simple PHP API client for tube-hosting.com rest API

Tube-Hosting API PHP client Explanation This PHP library is a simple api wrapper/client for the tube-hosting.com api. It is based on the provided docu

null 4 Sep 12, 2022
A lightweight REST API framework

php-microframework A minimal PHP 8 REST API built onto php-microframework. Features Automatic routing based on URL path, e.g. https://domain/controlle

John 1 Oct 16, 2021
GraphQL API to Studio Ghibli REST API

GhibliQL GhibliQL is a GraphQL wrapper to the Studio Ghibli REST API Usage First, you'll need a GraphQL client to query GhibliQL, like GraphQL IDE Con

Sebastien Bizet 8 Nov 5, 2022
Single file PHP script that adds a REST API to a SQL database

PHP-CRUD-API Single file PHP script that adds a REST API to a MySQL/MariaDB, PostgreSQL, SQL Server or SQLite database. NB: This is the TreeQL referen

Maurits van der Schee 3.2k Jan 8, 2023
PHP REST API without using any frameworks. Contains all CRUD operations.

PHP REST API without any framework and CRUD operations ?? Hi there, this is a simple REST API built in PHP without using any frameworks. This is built

Hanoak 10 Sep 5, 2022
Phalcon PHP REST API Package, still in beta, please submit issues or pull requests

PhREST API A Phalcon REST API package, based on Apigees guidelines as found in http://apigee.com/about/content/web-api-design Please see the skeleton

PhREST 29 Dec 27, 2022
example repository training REST API

adalah codebase REST-API dari tugas peserta yang mengikuti training membangun REST API dengan lumen selama 2 minggu. studi kasus nya adalah REST API website marketplace untuk agrobisniss.

Nuris Akbar 6 Sep 4, 2021
A REST API that should power the Agile Monkeys CRM Service

This is a simple REST API that purposes to power the Agile Monkeys CRM service

Dickens odera 3 Jul 31, 2021
Laravel Client REST Camunda API

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Uriel Reyes 1 Nov 5, 2021
Osclass REST API plugin.

Osclass API Osclass API plugin, with all the required endpoints and JWT auth. Osclass App (Native + PWA) You always wanted a mobile app for Osclass, d

Defected 4 Sep 10, 2022
Joy VoyagerApi module adds REST Api end points to Voyager with Passport and Swagger support.

Joy VoyagerApi This Laravel/Voyager module adds REST Api with Passport and Swagger support to Voyager. By ?? Ramakant Gangwar. Prerequisites Composer

Ramakant Gangwar 14 Dec 12, 2022
A rest api repository with laravel.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

kyo 2 Jan 17, 2022
A rest api repository with laravel.

API Back End This is the repository for the TKJ 1 Class 12 Web Back End API system, for detailed info, you can go to the main link of the Front End ap

kyo 2 Jan 17, 2022
A chess REST API.

Chess API A chess REST API. Documentation Read the latest docs here. Installation Clone the chesslablab/chess-api repo into your projects folder as it

ChesslabLab 6 Jan 5, 2023
API-Rest para información sobre administración-politica de Cuba

API_CUBA API desarrollada con Laravel PHP para brindar servicios REST para multiples plataformas sobre información politico administrativa de API_CUBA

Iosvany Alvarez 6 Mar 31, 2022
Extended response classes for Rest API clients/SDKs

Rest Response Extended response classes for Rest API clients/SDKs. About This package is intended to be component of SDKs so the responses can be easi

Ilesanmi Olawale Adedotun 2 Mar 28, 2022
A PHP library to support implementing representations for HATEOAS REST web services.

Hateoas A PHP library to support implementing representations for HATEOAS REST web services. Installation Working With Symfony Usage Introduction Conf

William Durand 998 Dec 5, 2022
Quickly and easily expose Doctrine entities as REST resource endpoints with the use of simple configuration with annotations, yaml, json or a PHP array.

Drest Dress up doctrine entities and expose them as REST resources This library allows you to quickly annotate your doctrine entities into restful res

Lee Davis 88 Nov 5, 2022