承接 jidoka1902/redirecting-fallbacks-symfony 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jidoka1902/redirecting-fallbacks-symfony

Composer 安装命令:

composer require jidoka1902/redirecting-fallbacks-symfony

包简介

Integration to the jidoka1902/redirecting-fallbacks project for symfony

README 文档

README

Symfony Integration for the "redirecting-fallbacks" project.

Examples

It's all about the configuration.

Basic Configuration

First of all, load the integration and library classes as services. So you can wire them as you need.

## config/services.yaml
services:
  Jidoka1902\RedirectingFallbacks\:
    resource: '%kernel.project_dir%/vendor/jidoka1902/redirecting-fallbacks/src'
  Jidoka1902\RedirectingFallbacksSymfony\:
    resource: '%kernel.project_dir%/vendor/jidoka1902/redirecting-fallbacks-symfony/src'

After that you can decide what type of routes you want to specify in your configuration files. Either plain paths like "/" and "/blog" or symfony named routes like "app_index".

For Symfony Routing - use the provided FrameworkUrlGeneratorAdapter:

## config/services.yaml
services:
  Jidoka1902\RedirectingFallbacks\UrlGenerator\UrlGenerator:
    alias: Jidoka1902\RedirectingFallbacksSymfony\UrlGenerator\FrameworkUrlGeneratorAdapter

If you prefer plain paths to redirect to use this config:

## config/services.yaml
services:
  Jidoka1902\RedirectingFallbacks\UrlGenerator\UrlGenerator:
    alias: Jidoka1902\RedirectingFallbacks\UrlGenerator\PassthroughUrlGenerator

Gloal Redirect on 404

Now that you know how to configure your prefered path-type - let's have a basic example about one redirect path for all occuring 404 Status Reasons (NotFoundHttpException or plain ResponseCode 404).

  • you have to wire the SingleRedirectResolver as alias for the RedirectResolver interface.
## config/services.yaml
services:
  Jidoka1902\RedirectingFallbacks\Resolver\RedirectResolver:
    alias: Jidoka1902\RedirectingFallbacks\Resolver\SingleRedirectResolver
  • configure the route to redirect to
## config/services.yaml
services:
  Jidoka1902\RedirectingFallbacks\Resolver\SingleRedirectResolver:
    arguments:
      $target: "/"

è voila! every request resulting in a 404 state will be redirected to "/"

More Precise Redirects depending on Paths

After that basic configuration, lets have a look at how to create more individual 404-redirects. E.g. if someone enters an not found blog url because of a wrong slug which was not found in your storage, should that be redirected to the start-page or do you have a fancy blog post search site? Same here:

  • link your desired RedirectResolver:
## config/services.yaml
services:
  Jidoka1902\RedirectingFallbacks\Resolver\RedirectResolver:
    alias: Jidoka1902\RedirectingFallbacks\Resolver\MultipleRedirectResolver
  • configure it:
## config/services.yaml
services:
  Jidoka1902\RedirectingFallbacks\Resolver\MultipleRedirectResolver:
    arguments:
      $mapping:
        - { path: '/blog/', target: 'app_blog_search'}
        - { path: '/', target: 'app_index'} 

But beware! the order of your mappings plays a role.

统计信息

  • 总下载量: 53
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2017-12-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固