PHPackages                             opb/slim-basic-auth - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. opb/slim-basic-auth

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

opb/slim-basic-auth
===================

HTTP Basic Auth Middleware for the Slim PHP Framework

0.2.2(11y ago)51.1k↓50%1MITPHPPHP &gt;=5.3.0

Since Jun 12Pushed 11y ago1 watchersCompare

[ Source](https://github.com/opb/slim-basic-auth)[ Packagist](https://packagist.org/packages/opb/slim-basic-auth)[ Docs](https://github.com/opb/slim-basic-auth)[ RSS](/packages/opb-slim-basic-auth/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (5)Used By (0)

Basic Auth Middleware for Slim
==============================

[](#basic-auth-middleware-for-slim)

This HTTP Basic Auth Middleware plugin for Slim. Key features:

- Protects a path and all sub-paths. For example, setting it to protect `/admin` will also protect `/admin/foo` and `/admin/bar/baz` but not `/foo`.
- Provides an interface `AuthCheckerInterface` for you to implement, in order to check a username/password combo against your own user database. An example is provided below of this in use.

Install
-------

[](#install)

Install via composer:

```
{
    "require": {
        "opb/slim-basic-auth": "dev-master"
    }
}
```

Usage
-----

[](#usage)

The `HttpBasicAuth` middleware class is instantiated with two parameters: a mandatory implementation of `AuthCheckerInterface` and an optional array of options. The two options currently supported are the `path` to match, and the `realm` if you wish to set that. The example below shows how you might implement this.

```
// MyAuthClass - implementing the required AuthCheckerInterface

class MyAuthClass implements \Slim\Middleware\AuthCheckerInterface
{
	// only function required by the interface
	public function checkCredentials($username, $password)	{
		// interact with your own auth system
		// do some stuff and return true if authorised, false if not
	}
}

// the rest of your Slim app, adding in the middleware

$app = new \Slim\Slim();

$authChecker = new MyAuthCLass;

$app->add(new \Slim\Middleware\HttpBasicAuth($authChecker, array(
	'path' => '/api', // optional, defaults to '/'
	'realm' => 'Protected API' // optional, defaults to 'Protected Area'
)));
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~79 days

Total

4

Last Release

4121d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d0de9060c9b99493ba089587b59b54d5e476f59076d3186a3b2201a90ddf9765?d=identicon)[opb](/maintainers/opb)

---

Top Contributors

[![opb](https://avatars.githubusercontent.com/u/778850?v=4)](https://github.com/opb "opb (8 commits)")

---

Tags

middlewareauthslimhttp auth

### Embed Badge

![Health badge](/badges/opb-slim-basic-auth/health.svg)

```
[![Health](https://phpackages.com/badges/opb-slim-basic-auth/health.svg)](https://phpackages.com/packages/opb-slim-basic-auth)
```

###  Alternatives

[dyorg/slim-token-authentication

Slim 3.0+ Token Authentication Middleware

78106.5k](/packages/dyorg-slim-token-authentication)[jeremykendall/slim-auth

Authorization and authentication for the Slim Framework using ZF2 Authentication and Acl components

24824.6k](/packages/jeremykendall-slim-auth)[chadicus/slim-oauth2-middleware

OAuth2 middleware for use within a Slim Framework API

48411.9k1](/packages/chadicus-slim-oauth2-middleware)[erjanmx/laravel-api-auth

Dead simple Laravel api authorization middleware

2024.5k](/packages/erjanmx-laravel-api-auth)[havenshen/slim-born

Slim Framework 3 skeleton application has authentication.

1941.7k](/packages/havenshen-slim-born)[potievdev/slim-rbac

Role Based Access Control middleware for Slim 3

345.5k1](/packages/potievdev-slim-rbac)

PHPackages © 2026

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