natanael-aguiar/safe-redirect

A simple way to redirect your pages with PHP easily and safely

v1.0.0 2023-10-13 11:30 UTC

This package is auto-updated.

Last update: 2024-11-13 14:51:14 UTC


README

Safe Redirect is a PHP package that provides a simple and safe way to perform HTTP redirects in your applications. It allows you to make redirects with customizable HTTP status codes, offering flexibility and security when handling user navigation.

Instalação

You can install Safe Redirect via Composer. Run the following command in the terminal:

composer require natanael-aguiar/safe-redirect

Use

To use Safe Redirect in your application, first, import the SafeRedirect class and then create an instance of it. You can pass a custom HTTP status code when creating the instance, or use the default status code, which is 302 (Found).

<?php

require_once 'vendor/autoload.php';

use SafeRedirect\SafeRedirect;

// Creating a SafeRedirect instance with custom status code (optional)
$redirect = new SafeRedirect(301);

// Redirecting to a specific URL
$redirect->to('https://example.com');

In the example above, a redirect to https://example.com is done with HTTP status code 301 (Moved Permanently).

Have fun!