2017 © Pedro PelĂĄez
 

library redirector

Manage your redirections easily.

image

freeq/redirector

Manage your redirections easily.

  • Wednesday, August 23, 2017
  • by patrykwozinski
  • Repository
  • 2 Watchers
  • 1 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Redirector

Redirect manager, (*1)

Build Status Total Downloads Latest Stable Version, (*2)

This package provides you with a simple tool to redirect users. You can easily manage everything., (*3)

Installation

Via Composer, (*4)

$ composer require freeq/redirector

Using

Use package everywhere you need. The best way to manage your redirections is to run it in Observer or other event listener. You should store redirections after saving to the database, drop them from store after removing database record. Every redirect object should implement Redirectable contract., (*5)

Create manager

Make instance of your redirections manager. It allows you to store/delete/flush/get data., (*6)

use Freeq\Redirector\Manager;

$redirect_object = Redirect::findById(1); // must implement Redirectable!

// Using file driver.
$storage = new FileStorage('/path/to/store/them');
$storage->setRedirect($redirect_object);
$manager = new Manager($storage);

// Using redis driver.
$storage = new RedisStorage(new Predis\Client());
$storage->setRedirect($redirect_object);
$manager = new Manager($storage);

// Otherwise u can use StorageFactory.
// $type is storage name (file or redis)
// $source is path for FileStorage or Predis Client for RedisStorage
$storage = StorageFactory::build($type, $source);
$storage->setRedirect($redirect_object);
$manager = new Manager($storage);

Manage Redirectable object

Store object, (*7)

$manager->store();

Drop it, (*8)

$manager->delete();

Flush everything, (*9)

$manager->flush();

Start redirection for given route, (*10)

$manager->forward('my_route');

Classes

  • Freeq\Redirector\Manager - allows you to manage.
  • Freeq\Redirector\StorageFactory - is creating concrete class depending of passed 'type' to the manager constructor.
  • Freeq\Redirector\Storages\FileStorage - driver which allows you to store redirections as mini files.
  • Freeq\Redirector\Storages\RedisStorage - driver which allows you to store redirections as redis records.

Redirectable methods

Your object which implements Freeq\Redirector\Contracts\Redirectable needs methods: - routeFrom() - which route should be redirected. - routeTo() - where did you want to go by your redirection (eg. https://github.com). - statusHttp() - redirect using specific http statuses (301 or 302). - hash() - hash is string similar to hashed routeFrom() by md5. It's redis key or filename. - expireAt() - returns date to expire your redirection., (*11)

Contributing

Please see contributing.md for details., (*12)

The Versions

23/08 2017

dev-master

9999999-dev

Manage your redirections easily.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Patryk WoziƄski

routing php7 redirections

22/08 2017

1.0.1

1.0.1.0

Manage your redirections easily.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Patryk WoziƄski

routing php7 redirections

12/08 2017

1.0.0

1.0.0.0

Manage your redirections easily.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Patryk WoziƄski