Skip to content
This repository has been archived by the owner on Mar 19, 2023. It is now read-only.
/ swapi-php Public archive
forked from rmasters/swapi-php

PHP wrapper library for SWAPI

License

Notifications You must be signed in to change notification settings

xvrmallafre/swapi-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP library for SWAPI

Build status Stable release License

## Usage

Install with Composer: composer require "rmasters/swapi:~1.0".

require_once __DIR__ . '/vendor/autoload.php';
use SWAPI\SWAPI;

$swapi = new SWAPI;

$swapi->characters()->index();  => Character[]
$swapi->characters()->index(2); => Character[]

$swapi->vehicles()->get(1);     => Vehicle <X-wing>
$swapi->planets()->get(7);      => Planet <Mustafar>

$swapi->people()->get(9999);    => null (not-found)

// Iteration
do {
    if (!isset($starships)) {
        $starships = $swapi->starships()->index();
    } else {
        $starships = $starships->getNext();
    }

    foreach ($starships as $s) {
        echo "{$s->name}\n";
    }
} while ($starships->hasNext());

## Running tests and contributing

Install dependencies with composer install --dev and run vendor/bin/phpunit to run the testsuite. The test suite comprises of:

License

MIT Licensed

About

PHP wrapper library for SWAPI

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%