RytrPhp is a simple SDK implementation of Rytr API. It helps accessing the API in an object oriented way.
Oficial Rytr-me page: https://rytr.me/
Oficial Rytr-me git documentation: https://github.com/rytr-me/documentation
please register an account and request an api key at Rytr.
Please check out the tutorials section for more information
You can install the package via composer:
composer require devkind/rytr-php
use Devkind\RytrPhp;
/** @var \Devkind\RytrPhp */
$rytr = new RytrPhp(API_KEY);
alternatively we can initialize static
/** @var \Devkind\RytrPhp */
$rytr = \Devkind\RytrPhp::make(API_KEY);
Endpoints are basically the type of content that is supported by Rytr.
Each endpoint requireds an $tone
and $language
parameter to query from rytr.
protected $language = '607adac76f8fe5000c1e636d'; //english
language="🇺🇸 English"
- language in which the texts will be generated - change using setLangugage()
protected $language = '607adac76f8fe5000c1e636d'; //english
tone="Casual"
- tones in which the text will be - change using setTone()
protected int $variations = 1;
variations = 1
- number of texts in response - change using setVariation()
protected string $format = 'text';
formats='html'
- html or text - ** change using setFormat()**
protected string $creativityLevel = 'default';
creativity_level='default'
- fault | none | low | medium | high | max - change using setCreativityLevel()
user_id='USER1'
- "For userId you need to supply user ID from your database, eg: primary key for users database table." - change using setUserId()
in order to change the language or tone we can call the setter methods, which is available on all the endpoints.
to set the language
/** @var \Devkind\RytrPhp\Endpoints\Usercases\BrandName */
$endpoint = $rytr->BrandName->setLanguage('english');
to set the tone
/** @var \Devkind\RytrPhp\Endpoints\Usercases\BrandName */
$endpoint = $rytr->BrandName->setTone('candid');
alternatively:
/** @var \Devkind\RytrPhp\Endpoints\Usercases\BrandName */
$endpoint = $rytr->BrandName->setTone('candid')->setLanguage('english')->setVariation(10);
All the endpoints can be called into three different ways
/** @var \Devkind\RytrPhp\Endpoints\UseCases\BrandName */
$endpoint = $object->BrandName;
$endpoint = $endpoint->get(['brandDescription' => "google"]);
/** @var \Devkind\RytrPhp\Endpoints\UseCases\BrandName */
$endpoint = $object->BrandName;
$endpoint = $endpoint
->setBrandDescription("google")
->setVariations(10)
->setUserId(100)
->setFormat('html')
->setCreativityLevel('medium')
->get();
/** @var \Devkind\RytrPhp\Endpoints\UseCases\BrandName */
$endpoint = $object->BrandName;
$endpoint = $endpoint->generate("google");
Click here to view the entire documentation of supported endpoints
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email backend@devkind.com.au instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.