Download the PHP package vormkracht10/laravel-redirects without Composer

On this page you can find all versions of the php package vormkracht10/laravel-redirects. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-redirects

Laravel Redirects

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A powerful and flexible Laravel package for managing HTTP redirects through a database-driven approach. Dynamically create, update, and track redirects without modifying code or redeploying your application.

Features

Table of Contents

Installation

You can install the package via Composer:

Publish and run the migrations:

This will create a redirects table with the following structure:

Column Type Description
ulid ULID Primary key
source string The source URL to redirect from
destination string The destination URL to redirect to
code integer HTTP status code (301, 302, 307, 308)
hits integer Number of times this redirect was triggered
created_at timestamp When the redirect was created
updated_at timestamp When the redirect was last modified

Optionally, publish the configuration file:

Configuration

The configuration file config/redirects.php provides extensive customization options:

Environment Variables

Add these to your .env file for environment-specific configuration:

Usage

Creating Redirects

Database Seeder

Programmatically

Via Tinker

Automatic Redirects via Events

The package includes an event-listener system to automatically create redirects when URLs change. This is useful when updating slugs or moving content:

This automatically creates a redirect in the database:

Integration Example with Eloquent Models:

Query String Handling

The package automatically preserves query strings from the source URL and appends them to the destination:

When a user visits:

They are redirected to:

If the destination already has query parameters:

Visiting /old-page?baz=qux redirects to:

Tracking Redirect Hits

Every time a redirect is triggered, the hits counter increments automatically:

Use this data for analytics and monitoring:

Middleware

The package includes three middleware classes, each with different matching strategies. They run in the order defined in config/redirects.php.

HttpRedirects

Matches URLs with protocol and www variations normalized:

This matches all of these URLs:

WildRedirects

Performs partial URL matching using contains():

This matches:

StrictRedirects

Exact URL matching without query strings:

This only matches:

But NOT:

Customizing Middleware Order

The middleware runs in the order defined in your config. First match wins:

You can reorder or remove middleware as needed. For example, to only use exact matching:

Advanced Usage

Custom Redirect Model

Create your own model extending the base Redirect model:

Update your config:

Managing Redirects Programmatically

Bulk Creation:

Import from CSV:

Conditional Redirects:

Redirect Chains (avoid these):

API Reference

Redirect Model

Properties:

Methods:

Events

UrlHasChanged Event:

Properties:

Listeners

RedirectOldUrlToNewUrl Listener:

Automatically creates a redirect when UrlHasChanged event is dispatched.

HTTP Status Codes

Understanding when to use each status code:

Code Name Use Case Cached by Browsers
301 Moved Permanently Permanent content relocation, old URL will never be used again Yes
302 Found Temporary redirect, old URL may be used again No
307 Temporary Redirect Temporary redirect that preserves HTTP method (POST stays POST) No
308 Permanent Redirect Permanent redirect that preserves HTTP method (POST stays POST) Yes

Recommendations:

Testing

Run the test suite:

Run tests with coverage:

Run static analysis:

Fix code style:

Writing Tests:

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details on how to contribute to this package.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Security Considerations:

Credits

License

The MIT License (MIT). Please see License File for more information.


Support

Built with by Backstage CMS


All versions of laravel-redirects with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
backstage/laravel-trailing-slash Version ^0.1
illuminate/contracts Version ^10.0 || ^11.0 || ^12.0||^13.0
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vormkracht10/laravel-redirects contains the following files

Loading the files please wait ...