A backend-for-frontend application used to demonstrate how to build it using PHP and GraphQL.
You will need the following things correctly installed on your computer.
- Clone the repository:
git clone https://github.com/taisreis67/web-php-bff.git
- Join inside repo:
cd web-php-bff
- Install project dependencies:
composer install
php -S localhost:8000 src/graphql.php
curl 'http://localhost:8000' -H 'Content-Type: application/json' -H 'Accept: application/json' --data-binary '{"query":"{movie(id: 550) { title, productionCompany { homepage }}}"}' | json_pp
You could test and see the results using GraphiQL Chrome Extension
The BFF is consuming a public API called TMDB (The Movie Database API) 3v.
To use it you need create an account at TMDB and generate an API Key. After that you need put your API Key in the url that call the API, example:
$url = 'https://api.themoviedb.org/3/movie/popular?api_key=your-api-key';