akiyamaSM / oxfordapi-wrapper by akiyamaSM

A PHP/Laravel Wrapper for oxford dictionary API
1,674
27
5
Package Data
Maintainer Username: akiyamaSM
Maintainer Contact: inanielhoussain@gmail.com (Inani El Houssain)
Package Create Date: 2017-01-17
Package Last Update: 2017-02-22
Language: PHP
License: MIT
Last Refreshed: 2024-11-22 03:08:37
Package Statistics
Total Downloads: 1,674
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 27
Total Watchers: 5
Total Forks: 6
Total Open Issues: 1

oxfordapi-wrapper

A PHP/Laravel Wrapper for oxford dictionary API

Installation

First, install the package through Composer.

composer require inani/oxfordapi-wrapper

Then include the service provider inside config/app.php.

'providers' => [
    ...
    Inani\OxfordApiWrapper\OxfordWrapperServiceProvider::class,
    ...
];

At least set up in the env file

OXFORD_API_BASE_URI = 
OXFORD_APP_ID = 
OXFORD_APP_KEY = 

make a new instance

// Make it or pass it as argument
$oxford = app(Inani\OxfordApiWrapper\OxfordWrapper::class);

How to use

Translation

// look for the translation from a language to an other, returns a parser
$parser =$oxford->lookFor('balablabla')
                ->from('en')
                ->to('es')
                ->translate();
                
// get array of translations
$translations = $parser->get();

// get array of [example => [translations]]
$examples = $parser->getExamples();

Definitions

// look for the definitions of a word, returns a parser
$parser =$oxford->lookFor('balablabla')
                ->define();
                
// get array of definitions
$definitions = $parser->get();

Examples

// look for the examples of a word, returns a parser
$parser =$oxford->lookFor('balablabla')
                ->examples();
                
// get array of examples
$definitions = $parser->get();

Thesaurus

// You can try all combinations
$res = $oxford->lookFor('happy')
               ->synonym()
               ->antonym()
               ->fetch();
                
// results will be related to (syno or anto)
// get synonyms and/or antonyms 
$res->get();
// get only antonyms or null if not specfied in fetch
$res->antonyms();
//get only synonyms or null if not specfied in fetch
$res->synonyms();

Phonetics


$res = $oxford->lookFor('ace')
               ->talk();
                
// get the array of result
$res->get();
// get the link to the audio file of pronunciation
$res->speak();
//get the spelling
$res->spell();
//get the notation
$res->notation();