8000 GitHub - alexandrecintra/basepath: PHP middleware to remove a path prefix from a request uri
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

alexandrecintra/basepath

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Base Path Middleware for PHP

This middleware just removes a prefix from the request uri.

Installation

This middleware can be installed with composer.

$ composer require los/basepath

Usage

Just add the middleware as one of the first in your application.

For example:

$app->pipe(new \LosMiddleware\BasePath\BasePath('/site'));

Every request with /site prefix will be replaced:

/site => /
/site/blog => /blog
/site/contact-us => /contact-us

Zend Expressive

If you are using expressive-skeleton, you can copy config/los-basepath.global.php.dist to config/autoload/los-basepath.global.php and modify configuration as your needs.

UrlHelper

Zend Expressive comes with a UrlHelper that generates a url for your application, but we need to inject the new basePath.

This modules comes with a UrlHelperFactory that does this job for you. Just add the following configuration:

'dependencies' => [
    'factories' => [
        Zend\Expressive\Helper\UrlHelper::class => LosMiddleware\BasePath\UrlHelperFactory::class,
        /* ... */
    ],
],

About

PHP middleware to remove a path prefix from a request uri

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%
0