PHPackages                             coolcode/authapi - 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. coolcode/authapi

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

coolcode/authapi
================

api authentication using sanctum

v1.0.0(1y ago)02MITPHP

Since Sep 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/kasunSujeewa/laravel-sanctum-api-auth)[ Packagist](https://packagist.org/packages/coolcode/authapi)[ RSS](/packages/coolcode-authapi/feed)WikiDiscussions main Synced yesterday

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

coolcode/authapi
================

[](#coolcodeauthapi)

`coolcode/authapi` is a Laravel package that simplifies API authentication using Laravel Sanctum. This package provides a set of endpoints for user registration, login, and logout functionality with token-based authentication.

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

[](#installation)

1. Install the package via Composer:

    ```
    composer require coolcode/authapi
    ```
2. Publish the Sanctum migrations:

    ```
    php artisan vendor:publish --tag=sanctum-migrations
    ```
3. Run the migrations:

    ```
    php artisan migrate
    ```
4. Finally, issue your Laravel Sanctum tokens when users authenticate with your API.

API Endpoints
-------------

[](#api-endpoints)

### 1. Register

[](#1-register)

**Endpoint:** `/api/register`
**Method:** `POST`
**Headers:**

- `Accept: application/json`
- `Content-Type: application/json`

**Request Body (form-data):**

KeyValueTypenametesttextemailtextpasswordpasswordtextconfirm\_passwordpasswordtext**Description:**
Registers a new user in the system.

### 2. Login

[](#2-login)

**Endpoint:** `/api/login`
**Method:** `POST`
**Headers:**

- `Accept: application/json`
- `Content-Type: application/json`

**Request Body (form-data):**

KeyValueTypeemailtextpasswordpasswordtext**Description:**
Authenticates the user and issues a Bearer token for future API requests. The token is stored in the environment variable `token`.

### 3. Logout

[](#3-logout)

**Endpoint:** `/api/logout`
**Method:** `POST`
**Headers:**

- `Accept: application/json`
- `Content-Type: application/json`
- `Authorization: Bearer {{token}}`

**Description:**
Logs the authenticated user out and invalidates the Bearer token.

Usage
-----

[](#usage)

Once you've installed the package and set it up, you can use these endpoints in your Postman collection or any API client to handle user authentication.

### Postman Example

[](#postman-example)

1. Register a user using the **Register** API.
2. Login using the **Login** API to get the Bearer token.
3. Set the token in your environment variables for future authenticated requests.
4. Logout the user using the **Logout** API.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

653d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/49329304?v=4)[kasunRanasinghe](/maintainers/kasunRanasinghe)[@KasunRanasinghe](https://github.com/KasunRanasinghe)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/coolcode-authapi/health.svg)

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

###  Alternatives

[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12 &amp; 13

6783.6k6](/packages/hasinhayder-tyro)[daniel-de-wit/lighthouse-sanctum

Laravel Sanctum support for Laravel Lighthouse.

61124.6k](/packages/daniel-de-wit-lighthouse-sanctum)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)[albetnov/sanctum-refresh

This package extends sanctum ability to be able to provide refresh token as well

211.7k](/packages/albetnov-sanctum-refresh)

PHPackages © 2026

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