PHPackages                             mr-timofey/laravel-simple-tokens - 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. mr-timofey/laravel-simple-tokens

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

mr-timofey/laravel-simple-tokens
================================

Simple token and cache based user authentication and authorization

0.3.0(6y ago)64.1k11MITPHPPHP &gt;=7.1.0

Since Dec 1Pushed 6y ago1 watchersCompare

[ Source](https://github.com/mrTimofey/laravel-simple-tokens)[ Packagist](https://packagist.org/packages/mr-timofey/laravel-simple-tokens)[ RSS](/packages/mr-timofey-laravel-simple-tokens/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (10)Used By (1)

Simple token and cache based user authentication and authorization.

You are tired of the mind-blowing, unnecessarily complex Passport OAuth? You want something configurable, manageable and simple? Then that is just the package you need.

Features
--------

[](#features)

- Fully Eloquent compatible auth driver
- Cache based token authorization with configurable TTL
- Additional query restriction configuration per each provider using simple `where/where in` clauses or model scopes (for example, you can restrict authorization only for particular user roles)
- Controller trait to maintain authentication/authorization/logout logic for your application out-of-the-box (but you still have to define controller and routes)
- Multiple independent guards support

Requirements
------------

[](#requirements)

- PHP 7.1
- Laravel 5

Install
-------

[](#install)

```
composer require mr-timofey/laravel-simple-tokens
```

**For Laravel &lt;= 5.4** add `MrTimofey\LaravelSimpleTokens\ServiceProvider` to your `app.providers` config.

```
php artisan vendor:publish --provider="MrTimofey\LaravelSimpleTokens\ServiceProvider"
```

Usage
-----

[](#usage)

Set your `auth.providers.users.driver` (replace `users` to other provider if needed) config to `simple`. Any authorized HTTP request must contain `Authorization: Bearer {api_token}` header.

Configure a guard (`api` by default) if necessary.

Use `MrTimofey\LaravelSimpleTokens\AuthenticatesUsers` trait with your auth controller. This trait adds methods:

- authenticate - authenticates user with login/email/password/remember\_token and returns JSON response which includes: ```
     {
     	user: { /* user data */ },
     	api_token: 'api token string',
     	remember_token: 'remember token string or NULL if request does not have a "remember" flag'
     }
    ```

    This method generates `api_token` and puts it to cache with `cache()->set('prefix:' . $token, $user_id, $ttl)`. Also regenerates user `remember_token`. TTL is configured in `simple_tokens.ttl`.
- logout - deletes `api_token` from cache.
- user - returns user data JSON.

Also you can define a `$guard` class field to use any guard other than default one (`api`).

### Auth provider configuration

[](#auth-provider-configuration)

```
// config/auth.php

return [

	// ...

	'providers' => [
		// Simple example (suitable for most cases)
		'simple' => [
			'driver' => 'simple',
			'model' => App\User::class
		],

		// Advanced example
		'advanced' => [
			'driver' => 'simple',
			'model' => App\User::class,

			// Query modifiers
			'only' => [
				// only users with email = example@email.com
				'email' => 'example@email.com',
				// only users with ID 1, 2 or 3
				'id' => [1, 2, 3]
			],

			// Any model scope
			'scope' => 'scopeName',
			// ...or
			'scope' => [
				'scopeName',
				'scopeWithArguments' => ['arg1', 'arg2']
			],

			// Cache prefix can be configured if you want to use multiple independent providers.
			// This will allow clients to have multiple tokens (one per each unique prefix).
			// On the other hand, you can restrict users to have a sinlgle token by providing same prefix.
			// Default: no prefix
			// IMPORTANT: this prefix will be appended to the `simple_tokens.cache_prefix` config entry.
			'cache_prefix' => '',

			// Token expiration time in minutes.
			// You can overwrite default value from the `simple_tokens.token_ttl` config entry here.
			'token_ttl' => 60
		]
	],

	// ...

];
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

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 ~110 days

Recently: every ~211 days

Total

9

Last Release

2201d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7864648122cd40602afa69f5bdf577684ae09f199ea2ab418c32005294bf89a2?d=identicon)[mrTimofey](/maintainers/mrTimofey)

---

Top Contributors

[![mrTimofey](https://avatars.githubusercontent.com/u/7373909?v=4)](https://github.com/mrTimofey "mrTimofey (17 commits)")

---

Tags

apiauthenticationauthorizationguardlaravellaravel-5-packagetokentraitlaravelauthtokenSimple

### Embed Badge

![Health badge](/badges/mr-timofey-laravel-simple-tokens/health.svg)

```
[![Health](https://phpackages.com/badges/mr-timofey-laravel-simple-tokens/health.svg)](https://phpackages.com/packages/mr-timofey-laravel-simple-tokens)
```

###  Alternatives

[jotaelesalinas/laravel-adminless-ldap-auth

Authenticate users in Laravel against an adminless LDAP server

2105.1k](/packages/jotaelesalinas-laravel-adminless-ldap-auth)[erjanmx/laravel-api-auth

Dead simple Laravel api authorization middleware

2024.5k](/packages/erjanmx-laravel-api-auth)[orchestra/auth

Auth Component for Orchestra Platform

24108.5k3](/packages/orchestra-auth)[ingria/laravel-x509-auth

Laravel 5 Client Certificate auth middleware

375.6k](/packages/ingria-laravel-x509-auth)

PHPackages © 2026

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