PHPackages                             waqar/apiauthentication - 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. waqar/apiauthentication

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

waqar/apiauthentication
=======================

A simple modified api authentication

1.0(3y ago)03MITPHP

Since May 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/WaqarHussainKhalid/mobile-api-authentication)[ Packagist](https://packagist.org/packages/waqar/apiauthentication)[ RSS](/packages/waqar-apiauthentication/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Laravel API Authentication
--------------------------

[](#laravel-api-authentication)

This is a Laravel package that provides easy-to-use API authentication using Laravel Passport. The package comes with pre-built controllers, middleware, and routes for registering users, authenticating users, and send opt on mail and phone number.

### Features

[](#features)

- Register new users
- Authenticate existing users
- Pre-built controllers, and routes for easy integration into your Laravel application
- Send otp on mail and phone number

Installation package
--------------------

[](#installation-package)

To install the package, run the following command:

```
composer require waqar/apiauthentication

```

Install Laravel Passport
------------------------

[](#install-laravel-passport)

```
composer require laravel/passport

```

Next, you should execute the passport:install Artisan command

```
php artisan passport:install

```

Finally, in your application's `config/auth.php` configuration file, you should define an `api` authentication guard and set the `driver` option to `passport`. This will instruct your application to use Passport's `TokenGuard` when authenticating incoming API requests:

```
'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],

    'api' => [
        'driver' => 'passport',
        'provider' => 'users',
    ],
],

```

For more information please visit the link: [Laravel Passport](https://laravel.com/docs/10.x/passport)

### Config file

[](#config-file)

1. Add the service provider to `app/config/app.php`

```
waqar\apiauthentication\ApiAuthenticationServiceProvider::class,

```

#### Step 2: Setup Database Configuration

[](#step-2-setup-database-configuration)

After successfully installing the laravel app then after configuring the database setup. We will open the ".env" file and change the database name, username and password in the env file.

```
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=Enter_Your_Database_Name
DB_USERNAME=Enter_Your_Database_Username
DB_PASSWORD=Enter_Your_Database_Password

```

#### Now, run migration with following command:

[](#now-run-migration-with-following-command)

```
php artisan migrate

```

#### Configure sender mail address in laravel .env file

[](#configure-sender-mail-address-in-laravel-env-file)

##### .env file:

[](#env-file)

```
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=587
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=TLS

```

#### Create Twilio Account

[](#create-twilio-account)

First you need to create and add phone number. then you can easily get account SID, Token and Number.

Create Account from here: [www.twilio.com](http://www.twilio.com).

Next add Twilio Phone Number

Next you can get account SID, Token and Number and add these in the .env file like bellow:

#### .env

[](#env)

```
TWILIO_ACCOUNT_SID=XXXXXXXXXXXXXXXXX
TWILIO_AUTH_TOKEN=XXXXXXXXXXXXX
TWILIO_NUMBER=+XXXXXXXXXXX

```

### Usage

[](#usage)

The package comes with pre-built controllers, and routes for registering users, authenticating users. To use these features, simply include the package's routes in your Laravel application's routes/api.php file:

You can then make API requests to the following endpoints:

- `/api/register`: Register a new user
- `/api/login`: Authenticate an existing user and retrieve an access token
- `/api/sendOtpEmail`: send otp on mail
- `/api/sendOtpPhoneNumber`: send otp on phone number
- `/api/verifyOtp`: Verify otp

#### Note

[](#note)

Please add `Accept:application/json` in headers

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

Unknown

Total

1

Last Release

1096d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/04b5f5b3815b9dd159be6a09489fd518d1b500eb8c4c250795105b2965da4222?d=identicon)[WaqarHussainKhalid](/maintainers/WaqarHussainKhalid)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/waqar-apiauthentication/health.svg)

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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