PHP code example of enflow / redirect-pizza-php-sdk

1. Go to this page and download the library: Download enflow/redirect-pizza-php-sdk 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/ */

    

enflow / redirect-pizza-php-sdk example snippets


$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();
composer