spadbob/urlencode

允许在路由参数中编码URL编码的斜杠和更多字符

1.0.2 2014-07-09 14:53 UTC

This package is not auto-updated.

Last update: 2024-10-02 11:18:09 UTC


README

覆盖Laravel 4的默认路由,允许包括斜杠在内的所有字符进行编码!

Composer配置

在您的 composer.json 中将 artistan urlencode 包作为依赖项包括 Packagist

"spadbob/urlencode": "1.0.*"

安装

更新您的composer配置后,运行 composer install 下载依赖项。

将ServiceProvider添加到 app/config/app.php 中的providers数组

'providers' => array(

	'Artistan\Urlencode\UrlencodeServiceProvider',

)

Apache conf https://httpd.apache.ac.cn/docs/2.2/mod/core.html#allowencodedslashes

AllowEncodedSlashes On|NoDecode

警告

Ensure all your routes are properly rawurlencoded!

This package will actually break your routing IF you do not have valid urls in your routes.

Laravel Bug修复

([Bug] urlencoded slashes in routing parameters)[https://github.com/laravel/framework/pull/4338]
Current routes do not allow for urlencoded slashes in the paths.
This is problematic when trying to create ecommerce solutions with partnumbers in the routes
since many part numbers have slashes in them. There are also quite a few
manufacturers with slashes in their names and or brands. This package provides
the functionality to allow an uri to have encoded slashes, and other characters,
in the (routes)[https://laravel.net.cn/docs/routing] and also to
(create routes with those parameters)[https://laravel.net.cn/docs/routing#route-parameters].

 An example url may be...

    https://stage.test.com/part/Cisco%20Systems%2C%20Inc/CISCO2851-SRST%2FK9

    Route::any('/part/{mfg}/{part}',
        array(
            'uses' =>'Vendorname\Package\Controllers\Hardware\PartController@part',
            'as' => 'part_page'
        )
    );

用法

With that said it WILL allow all characters to be rawurlencoded as parameters in your routes without breaking parameters and/or routes.