2017-25 © Pedro Peláez
 

library base-path

Middleware to remove the prefix from the uri path of the request.

image

middlewares/base-path

Middleware to remove the prefix from the uri path of the request.

  • Wednesday, January 24, 2018
  • by oscarotero
  • Repository
  • 2 Watchers
  • 0 Stars
  • 852 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 19 % Grown

The README.md

middlewares/base-path

Latest Version on Packagist ![Software License][ico-license] Testing ![Total Downloads][ico-downloads], (*1)

Middleware to remove the prefix from the uri path of the request. This is useful to combine with routers if the root of the website is in a subdirectory. For example, if the root of your website is /web/public, a request with the uri /web/public/post/34 will be converted to /post/34., (*2)

Requirements

Installation

This package is installable and autoloadable via Composer as middlewares/base-path., (*3)

composer require middlewares/base-path

Usage

Set the prefix to remove:, (*4)

Dispatcher::run([
    new Middlewares\BasePath('/base/path')
]);

fixLocation

Used to add the prefix to the Location header (for redirects). For example:, (*5)

$response = Dispatcher::run([
    (new Middlewares\BasePath('/base/path'))->fixLocation(),

    function () {
        return Factory::createResponse(301)->withHeader('Location', '/post/1');
    }
]);

echo $response->getHeader('Location'); // Returns /base/path/post/1

attribute

This method will store the original path in an attribute., (*6)

// Save the original uri with basepath in the custom attribute "before-basepath-uri"
$basepath = (new Middlewares\BasePath())->attribute('pre-basepath-path');

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details., (*7)

The MIT License (MIT). Please see LICENSE for more information., (*8)

The Versions

24/01 2018

dev-master

9999999-dev https://github.com/middlewares/base-path

Middleware to remove the prefix from the uri path of the request.

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http psr-15

24/01 2018

v1.0.0

1.0.0.0 https://github.com/middlewares/base-path

Middleware to remove the prefix from the uri path of the request.

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http psr-15

13/11 2017

v0.5.0

0.5.0.0 https://github.com/middlewares/base-path

Middleware to remove the prefix from the uri path of the request.

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http psr-15

21/09 2017

v0.4.0

0.4.0.0 https://github.com/middlewares/base-path

Middleware to remove the prefix from the uri path of the request.

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http psr-15

26/12 2016

v0.3.0

0.3.0.0 https://github.com/middlewares/base-path

Middleware to remove the prefix from the uri path of the request.

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http psr-15

22/11 2016

v0.2.0

0.2.0.0 https://github.com/middlewares/base-path

Middleware to remove the prefix from the uri path of the request.

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http psr-15

02/10 2016

v0.1.1

0.1.1.0 https://github.com/middlewares/base-path

Middleware to remove the prefix from the uri path of the request.

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http psr-15

01/10 2016

v0.1.0

0.1.0.0 https://github.com/middlewares/base-path

Middleware to remove the prefix from the uri path of the request.

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http psr-15