Download the PHP package bulton-fr/bfw-api without Composer
On this page you can find all versions of the php package bulton-fr/bfw-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bulton-fr/bfw-api
More information about bulton-fr/bfw-api
Files in bulton-fr/bfw-api
Package bfw-api
Short Description API module for BFW
License LGPL-3.0
Homepage https://github.com/bulton-fr/bfw-api
Informations about the package bfw-api
bfw-api
Module to use an API with the BFW framework
Install :
You can use composer to get the module : composer require bulton-fr/bfw-api @stable
And to install the module : ./vendor/bin/bfwInstallModules
Config :
All config file for this module will be into app/config/bfw-api/
. There are two files to configure (manifest.json is for the module update system).
First, the file config.php
urlPrefix
: The prefix of all url used by the api.useRest
: If the API will use the REST formatuseGraphQL
: If the API will use the GraphQL format. But you can't use it for the moment, it's not implemented yet ! (issue #2)
Next, the file routes.php
It's all routes of your api. The prefix write into the other config file should not be added into the route url. To know the route format to use, please refer you to the exemple write into the routes.php config file.
Note : If not method is present, the route will respond to all http methods (get, set, put and delete).
Use it :
I will only explain to REST API because the GraphQL API is not implemented yet. I will update this section when it will implemented.
You will create you API class controllers into the directory /src/api/. All classes should extends the class \BfwApi\Rest class.
You will add a method for each used HTTP method for you controller. All datas receive from the request will be present into the property $datas
. Il you want return an response, you can use the method sendResponsesendResponse(&$response)
. This method will automaticaly detect the response format to use (xml or json) from the HTTP request and convert your response to the correct format before sent it.
Example :
Configs :
Controller class :
All versions of bfw-api with dependencies
nikic/fast-route Version ~v1.3
bulton-fr/php-to-xml Version 1.0.0