PHP code example of jlgomes / swapi-php
1. Go to this page and download the library: Download jlgomes/swapi-php 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/ */
jlgomes / swapi-php example snippets
use Jlgomes\Swapi\Swapi;
$swapi = new Swapi();
$dataStarships = $swapi->getDataByUrl("https://swapi.dev/api/starships/5");
// Resultado em: https://github.com/jonasbenti/fetch-swapi-data/blob/master/attachment/Sample1.png
echo($dataStarships);
use Jlgomes\Swapi\Swapi;
$swapi = new Swapi();
$dataPeople = $swapi->getDataByModelAndId('people', 5, true);
// Resultado em: https://github.com/jonasbenti/fetch-swapi-data/blob/master/attachment/Sample2.json
echo($dataPeople);
bash
composer