PHPackages                             slam/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. slam/basepath

ActiveLibrary

slam/basepath
=============

PHP middleware to remove a path prefix from request uri

v3.0.0(5y ago)0216MITPHPPHP ^7.4 || ^8.0

Since Nov 20Pushed 5y agoCompare

[ Source](https://github.com/Slamdunk/basepath)[ Packagist](https://packagist.org/packages/slam/basepath)[ Docs](https://github.com/lansoweb/basepath)[ Fund](https://paypal.me/filippotessarotto)[ GitHub Sponsors](https://github.com/Slamdunk)[ RSS](/packages/slam-basepath/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (16)Versions (10)Used By (0)

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

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

[![Latest Stable Version](https://camo.githubusercontent.com/dfa27d6b58812d936eb4216b90ce0b9eadb37114e2b8c5ddbcea3e4998f26166/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736c616d2f62617365706174682e737667)](https://packagist.org/packages/slam/basepath)[![Downloads](https://camo.githubusercontent.com/73be8a3a8895aa278d7e8a37b67780a6ba034ccfb48de269e47e4fb4e2062391/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736c616d2f62617365706174682e737667)](https://packagist.org/packages/slam/basepath)[![Integrate](https://github.com/Slamdunk/basepath/workflows/Integrate/badge.svg?branch=master)](https://github.com/Slamdunk/basepath/actions)

This middleware just removes a prefix from the request uri.

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

[](#installation)

This middleware can be installed with composer.

```
$ composer require slam/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 (formely Zend Expressive)

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

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 69.7% 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 ~276 days

Recently: every ~413 days

Total

8

Last Release

1896d ago

Major Versions

0.9.1 → 1.0.02016-08-05

1.0.1 → 2.0.02018-03-27

2.1.0 → v3.0.02021-03-09

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

1.0.0PHP ^7.0

2.0.0PHP ^7.1

v3.0.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/50348?v=4)[Sahn Lam](/maintainers/Slam)[@slam](https://github.com/slam)

---

Top Contributors

[![Lansoweb](https://avatars.githubusercontent.com/u/2109813?v=4)](https://github.com/Lansoweb "Lansoweb (23 commits)")[![Slamdunk](https://avatars.githubusercontent.com/u/152236?v=4)](https://github.com/Slamdunk "Slamdunk (4 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

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[bref/bref

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

3.4k9.6M55](/packages/bref-bref)[thecodingmachine/graphqlite

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

5723.1M30](/packages/thecodingmachine-graphqlite)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

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

The next generation PHP framework.

25639.1k1](/packages/windwalker-framework)

PHPackages © 2026

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