Download the PHP package setono/sylius-redirect-plugin without Composer

On this page you can find all versions of the php package setono/sylius-redirect-plugin. 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 sylius-redirect-plugin

Sylius Redirect Plugin

Latest Version on Packagist Build Status

Gives you the ability to manage redirects in your Sylius shop.

Installation

Step 1: Download the plugin

Open a command console, enter your project directory and execute the following command to download the latest stable version of this plugin:

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the plugin

Then, enable the plugin by adding it to the list of registered plugins/bundles in the config/bundles.php file of your project:

It is IMPORTANT to add the plugin before the grid bundle, otherwise you will get an exception saying You have requested a non-existent parameter "setono_sylius_redirect.model.redirect.class".

Step 3: Import routes

The imported file already prefixes the admin routes with /%sylius_admin.path_name%, so no extra prefix: is needed.

Step 4: Update database

Use Doctrine migrations to create a migration file and update the database.

Step 5: Install assets

What it does

This plugin allows you to create new redirects.

Under the new menu entry Redirects under Configuration, you can manage redirects.

Redirection entry

An entry is composed by:

Security

There is a built-in safeguard when creating/modifying a redirect that prevents infinite loops. It walks the redirect chain recursively and refuses to save a redirect that would cycle.

A second safeguard prevents two enabled redirects from sharing the same source URL within the same channel scope (or globally, if neither uses channels) — otherwise the runtime would have to pick between two inconsistent destinations. The admin form additionally probes the AJAX endpoint /admin/ajax/redirects/check-source while you type and surfaces a warning with a link to the conflicting redirect, so you can spot the collision before submitting.

Disabling non-404 redirects

By default the plugin checks for a matching redirect on every request, so a only404 = false redirect can intercept the request before the controller runs. That convenience comes at the cost of one database query per request, even on installations that exclusively use only404 = true redirects.

If you only ever use 404-only redirects, disable the always-on listener:

When false, the plugin no longer registers its KernelEvents::REQUEST listener — there is zero per-request overhead. Redirects continue to work on the 404 path, which is all you need when every redirect has only404 = true. The admin form drops the Only when 404 checkbox and a class-level constraint on Redirect rejects any save (form, API, CLI, fixtures) where only404 = false, so you can't accidentally create a row that would never fire. Pre-existing only404 = false rows go dormant until you either flip the option back, delete them, or set their only404 to true.

Pruning unused redirects

The bundled setono:sylius-redirect:prune command deletes redirects that have not been accessed in the last N days. Configure the threshold under remove_after:

Then schedule the command (cron, messenger cron, deploy hook, …):

Pruning iterates eligible redirects in batches via ocramius/doctrine-batch-utils, so it stays memory-safe even on tables with millions of rows.

Automatic redirects on slug changes

When you opt in, the plugin creates a redirect every time an admin renames the slug of a configured Sylius resource. Opt-in is per resource alias and defaults to off everywhere:

Aliases must implement Sylius\Component\Resource\Model\SlugAwareInterface. Unknown aliases or non-slug-aware models fail container compilation with a clear error.

Each automatic redirect is created with these fixed defaults: permanent = true, only404 = true, no channel scope, enabled = true. only404 = true means the redirect kicks in only when the request would otherwise 404 — so if the slug is later rolled back to its original value, the entry self-heals without you having to clean up. The plugin also collapses chains: if you rename a → b and then b → c, the earlier a → b redirect is replaced with a → c.

The trigger is admin-only: only edits that flow through Sylius's ResourceController::updateAction create redirects. API edits, fixture loads, CLI scripts, and direct repository writes do not.

Adding coverage for your own resources

To redirect on slug changes for a custom resource, register a service implementing Setono\SyliusRedirectPlugin\UrlResolver\AutomaticRedirectUrlResolverInterface and tag it setono_sylius_redirect.automatic_redirect_url_resolver:

...then enable the alias under automatic_redirects: app.blog_post: true.

Development

This project uses OpenSpec to plan and track non-trivial features. Active proposals live under openspec/changes/<name>/; the current accepted specs live under openspec/specs/<capability>/; completed proposals move to openspec/changes/archive/. If you're contributing a sizeable change, write the proposal / design / spec / tasks artifacts there first so the why and the contract are clear before any code lands.


All versions of sylius-redirect-plugin with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
doctrine/collections Version ^2.2
doctrine/persistence Version ^1.3 || ^2.1 || ^3.0 || ^4.0
league/uri Version ^6.0 || ^7.5
league/uri-components Version ^2.3 || ^7.5
ocramius/doctrine-batch-utils Version ^2.4
psr/log Version ^1.1 || ^2.0 || ^3.0
setono/composite-compiler-pass Version ^1.2
setono/doctrine-orm-trait Version ^1.2
sylius/channel Version ^2.0
sylius/channel-bundle Version ^2.0
sylius/core-bundle Version ^2.0
sylius/product Version ^2.0
sylius/resource-bundle Version ^1.12
sylius/taxonomy Version ^2.0
sylius/ui-bundle Version ^2.0
symfony/config Version ^6.4 || ^7.1
symfony/console Version ^6.4 || ^7.1
symfony/dependency-injection Version ^6.4 || ^7.1
symfony/event-dispatcher Version ^6.4 || ^7.1
symfony/form Version ^6.4 || ^7.1
symfony/http-foundation Version ^6.4 || ^7.1
symfony/http-kernel Version ^6.4 || ^7.1
symfony/routing Version ^6.4 || ^7.1
symfony/validator Version ^6.4 || ^7.1
twig/twig Version ^3.0
webmozart/assert Version ^1.11
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 setono/sylius-redirect-plugin contains the following files

Loading the files please wait ...