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)14132.4k—0%4MITPHPPHP ^7.4 || ^8.0

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 1mo ago

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 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

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

1861d 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.8k18.5M1.6k](/packages/cakephp-cakephp)[thecodingmachine/graphqlite

Write your GraphQL queries in simple to write controllers (using webonyx/graphql-php).

5723.1M30](/packages/thecodingmachine-graphqlite)[jaxon-php/jaxon-core

Jaxon is an open source PHP library for easily creating Ajax web applications

73142.3k25](/packages/jaxon-php-jaxon-core)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)

PHPackages © 2026

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