PHPackages                             los/basepath - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. los/basepath

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

los/basepath
============

PHP middleware to remove a path prefix from request uri

2.2.0(5y ago)14135.3k—3.5%4MITPHPPHP ^7.4 || ^8.0CI failing

Since Nov 20Pushed 5y ago2 watchersCompare

[ Source](https://github.com/Lansoweb/basepath)[ Packagist](https://packagist.org/packages/los/basepath)[ Docs](https://github.com/lansoweb/basepath)[ GitHub Sponsors](https://github.com/Lansoweb)[ RSS](/packages/los-basepath/feed)WikiDiscussions 2.3.x Synced yesterday

READMEChangelog (2)Dependencies (11)Versions (13)Used By (0)

Base Path Middleware for PHP
============================

[](#base-path-middleware-for-php)

This middleware just removes a prefix from the request uri.

Installation
------------

[](#installation)

This middleware can be installed with composer.

```
$ composer require los/basepath
```

Usage
-----

[](#usage)

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

For example:

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

Every request with `/site` prefix will be replaced:

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

```

### Mezzio (formerly Zend Expressive)

[](#mezzio-formerly-zend-expressive)

If you are using [mezzio-skeleton](https://github.com/mezzio/mezzio-skeleton), you can copy `config/los-basepath.global.php.dist` to `config/autoload/los-basepath.global.php`and modify configuration as your needs.

Then, add the middleware to your pipeline:

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

### Dynamic base path

[](#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:

```
$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 ...
];
```

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 82.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~219 days

Recently: every ~271 days

Total

10

Last Release

1907d ago

Major Versions

0.9.1 → 1.0.02016-08-05

1.0.1 → 2.0.02018-03-27

PHP version history (4 changes)0.9.0PHP ^5.5|^7.0

1.0.0PHP ^7.0

2.0.0PHP ^7.1

2.2.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b54dffc1ebcb317a0cf825a781ab6c5f30980e9abd0d0a3f9c68830cb05c014?d=identicon)[Lansoweb](/maintainers/Lansoweb)

---

Top Contributors

[![Lansoweb](https://avatars.githubusercontent.com/u/2109813?v=4)](https://github.com/Lansoweb "Lansoweb (28 commits)")[![samsonasik](https://avatars.githubusercontent.com/u/459648?v=4)](https://github.com/samsonasik "samsonasik (3 commits)")[![alexandrecintra](https://avatars.githubusercontent.com/u/467760?v=4)](https://github.com/alexandrecintra "alexandrecintra (1 commits)")[![halfpastfouram](https://avatars.githubusercontent.com/u/3202331?v=4)](https://github.com/halfpastfouram "halfpastfouram (1 commits)")[![papagei-il](https://avatars.githubusercontent.com/u/19528397?v=4)](https://github.com/papagei-il "papagei-il (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/los-basepath/health.svg)

```
[![Health](https://phpackages.com/badges/los-basepath/health.svg)](https://phpackages.com/packages/los-basepath)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[mcp/sdk

Model Context Protocol SDK for Client and Server applications in PHP

1.5k1.5M88](/packages/mcp-sdk)[bref/bref

Bref is a framework to write and deploy serverless PHP applications on AWS Lambda.

3.4k10.6M67](/packages/bref-bref)[typo3/cms-core

TYPO3 CMS Core

3713.2M5.1k](/packages/typo3-cms-core)[xima/xima-typo3-frontend-edit

Frontend Edit - This extension provides an edit button for editors within frontend content elements.

1414.3k](/packages/xima-xima-typo3-frontend-edit)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
