2017 © Pedro Peláez
 

library basepath

PHP middleware to remove a path prefix from request uri

image

los/basepath

PHP middleware to remove a path prefix from request uri

  • Monday, April 23, 2018
  • by Lansoweb
  • Repository
  • 2 Watchers
  • 7 Stars
  • 12,606 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 8 Versions
  • 15 % Grown

The README.md

Base Path Middleware for PHP

This middleware just removes a prefix from the request uri., (*1)

Installation

This middleware can be installed with composer., (*2)

$ composer require los/basepath

Usage

Just add the middleware as one of the first in your application., (*3)

For example:, (*4)

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

Every request with /site prefix will be replaced:, (*5)

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

Mezzio (formely Zend Expressive)

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

Then, add the middleware to your pipeline:, (*7)

$app->pipe(LosMiddleware\BasePath\BasePathMiddleware::class);

Dynamic base path

In some cases a dynamic base path might be required. This can be achieved with the following code in your configuration file:, (*8)

$scriptPath = dirname($_SERVER['SCRIPT_NAME']);
return [
    // Use directory of script path if available, otherwise default to empty string.
    'los_basepath' => strlen($scriptPath) > 1 ? $scriptPath : '',

    // rest of the configuration ...
];

The Versions

27/08 2016

1.0.1

1.0.1.0 https://github.com/lansoweb/basepath

PHP middleware to remove a path prefix from request uri

  Sources   Download

MIT

The Requires

 

The Development Requires

27/08 2016

dev-develop

dev-develop https://github.com/lansoweb/basepath

PHP middleware to remove a path prefix from request uri

  Sources   Download

MIT

The Requires

 

The Development Requires

20/11 2015