Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/enflow/redirect-pizza-php-sdk

An SDK written in PHP to work with redirect.pizza
https://github.com/enflow/redirect-pizza-php-sdk

Last synced: about 2 months ago
JSON representation

An SDK written in PHP to work with redirect.pizza

Awesome Lists containing this project

README

        

# SDK to easily work with the redirect.pizza API

[![redirect.pizza](https://redirect.pizza/favicons/open-graph.png)](https://redirect.pizza?ref=github)

[![Latest Version on Packagist](https://img.shields.io/packagist/v/enflow/redirect-pizza-php-sdk.svg?style=flat-square)](https://packagist.org/packages/enflow/redirect-pizza-php-sdk)
![GitHub Workflow Status](https://github.com/enflow/redirect-pizza-php-sdk/workflows/run-tests/badge.svg)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Total Downloads](https://img.shields.io/packagist/dt/enflow/redirect-pizza-php-sdk.svg?style=flat-square)](https://packagist.org/packages/enflow/redirect-pizza-php-sdk)

## Installation

```composer require enflow/redirect-pizza-php-sdk```

## Usage

```php
$apiToken = 'rpa_XXXXXXXXXXXXXXXXXXX'; // You can find this token on https://redirect.pizza/api

$redirectPizza = new \RedirectPizza\PhpSdk\RedirectPizza($apiToken);

// List all redirects
$redirectPizza->redirects();

// Create redirect
$redirect = $redirectPizza->createRedirect([
'sources' => ['old-source.nl'],
'destination' => 'new-fancy-site.nl',
'redirect_type' => 'permanent',
'keep_query_string' => false,
]);

// Fetch redirect
$redirectPizza->redirect($redirect->id);

// Update redirect
$redirect->update([
'sources' => ['old-source.nl'],
'destination' => 'new-fancy-site-v2.nl',
'redirect_type' => 'permanent',
'keep_query_string' => true,
]);

// Delete the redirect
$redirect->delete();
```

## Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

## Credits

- [Michel Bardelmeijer](https://github.com/mbardelmeijer)
- [All Contributors](../../contributors)

This package uses code from and is greatly inspired by the [OhDear PHP SDK](https://github.com/ohdearapp/ohdear-php-sdk) by [Freek van der Herten](https://github.com/freekmurze) and [Mattias Geniar](https://github.com/mattiasgeniar), which is based on [Forge SDK package](https://github.com/themsaid/forge-sdk) by [Mohammed Said](https://github.com/themsaid).

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.