PHPackages                             appkita/phpauth - 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. appkita/phpauth

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

appkita/phpauth
===============

:Small library PHP for authentication support facebook, google, key, jwt, diggest, basic and session

2.1.1(3y ago)717111MITPHPPHP &gt;=7.0

Since May 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/gunantos/PHP_AUTHENTICATION)[ Packagist](https://packagist.org/packages/appkita/phpauth)[ Fund](http://sponsor.app-kita.net/)[ GitHub Sponsors](https://github.com/gunantos)[ RSS](/packages/appkita-phpauth/feed)WikiDiscussions main Synced 5d ago

READMEChangelog (4)Dependencies (4)Versions (12)Used By (1)

PHP AUTHENTICATION
==================

[](#php-authentication)

[APP KITA](https://app-kita.com)

### *Simple Library PHP Authentication API*

[](#simple-library-php-authentication-api)

[![](https://camo.githubusercontent.com/57587246441d07c3ab257eedac62a1936f24ec126b634bdf27af9938c872c06f/68747470733a2f2f6170702d6b6974612e636f6d2f696d672f6c6f676f2d74656b732e39363564323462662e706e67)](https://app-kita.com)
[![Build Status](https://camo.githubusercontent.com/dcfe77b03cfc05086e8684239dc8e6da9ef5c97843be6a9d5797461e541e8069/68747470733a2f2f7777772e7472617669732d63692e636f6d2f67756e616e746f732f5048505f41555448454e5449434154494f4e2e7376673f6272616e63683d6d61696e)](https://www.travis-ci.com/gunantos/PHP_AUTHENTICATION)

Sample Library PHP Authentication Restfull API

- Support Multi Authentication

### new version 2.1

[](#new-version-21)

- add Session auth

    ```
    use Appkita\PHPAuth;
    $config = [
        'session' => [
            'session_key'=>'isLogin'
        ]
    ];
    $auth = new Authentication($config);
    $cek = $auth->auth(METHOD::SESSION, function($auth) {
        return ($auth ? true : false);
    });
    ```
- add Google Auth and Facebook Auth

    ```
    $configApi = [
        'google' = [
        'clientID' => 'your client id',
        'clientSecret' => 'secret client',
        'redirectUri' => 'redirect url',
      ];
       'facebook' = [
        'clientID' => 'your client id',
        'clientSecret' => 'secret client',
        'redirectUri' => 'redirect url',
      ];
    ]

    //identifikasi Facebook Library
    $FB = new \Appkita\PHPAuth\Type\Facebooklogin($configApi);
    //identifikas google library
    $GOOGLE = new \Appkita\PHPAuth\Type\GoogleLogin($this->configApi);

    //get FB login url
    function loginFB() {
        header('location:'. $FB->urlLogin());
    }

    //get Google Login url
    function loginGoogle() {
        header('location:'. $GOOGLE->urlLogin());
    }

    //url callback fb login to verify token
    function verify_fb() {
        return $FB->decode(function($user, $args, $error) {
              die(json_encode($user));
          });
    }
    //url callback fb Google to verify token
    function verify_fb() {
        return $FB->decode(function($user, $args, $error) {
              die(json_encode($user));
          }, []);
    }
    ```

    more info \[Google Doc\] () more info \[Facebook Document\] ()

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

[](#installation)

Dillinger requires [PHP](https://php.net/) v7.0+ to run.

Install composer follow [composer](https://getcomposer.org/download/)

```
composer require appkita/phpauth
```

or

Edit composer.json and update composer

```
{
    "require": {
        "appkita/phpauth": "^0.1.*"
    }
}
```

Features
--------

[](#features)

- API KEY Authentication
- JWT Authentication (Token)
- Basic Authentication
- Digest Authentication
- Google Auth
- Facebook Auth
- SESSION

Using
-----

[](#using)

*configuration*

```
  $config = [
    'key_header'=>'X-API-KEY', //Delete if you not use API KEY
    //jwt Configuration
    'key'=>'key_JWT',
    'data'=>'username',
    'timeout'=>3600,
    'iss'=>'mydomain.com',
    'aud'=>'mydomain.com',
    'basic_auth'=>[
        'username_key'=>'email',
        'password_key'=>'password'
    ];
  ];
  $auth = new Appkita\PHPAuth\Authentication($config);
  //or
  use Appkita\PHPAuth;
  $auth = new Authentication($config);
  //or configuration default
  $auth = new Authentication();
```

```
    $cek = $auth->auth(METHOD, callback);
```

*callback* : is function to cek username or key you can set return or die but if you using digest authentication you must return array

```
return ['username'=>username, 'password'=>password];
```

```
    method Support
    METHOD::Key = 'key',
    METHOD::Basic = 'basic',
    METHOD::Digest = 'digest'
    METHOD::Token = 'token' //is JWT Authentication
```

*Example*

### 1. KEY

[](#1-key)

```
    $mykey = 'testingkey';
    $cek = $auth->auth(METHOD::KEY, function($key) {
        if ($key === $mykey) {
            return true;
        } else {
            return false;
        }
    });
```

### 2. BASIC

[](#2-basic)

```
    $myusername = 'testingkey';
    $mypassword = 'password';
    $cek = $auth->auth(METHOD::BASIC, function($username, $password) {
        if ($username == $myusername && $mypassword == $password) {
            return true;
        } else {
            return false;
        }
    });
```

### 3. DIGEST

[](#3-digest)

```
    $myusername = 'testingkey';
    $mypassword = 'password';
    $cek = $auth->auth(METHOD::DIGEST, function($username, $password) {
        if ($username == $myusername) {
            return ['username'=>$myusername, 'password'=>$mypassword];
        } else {
            return false;
        }
    });
```

### 4. TOKEN (JWT)

[](#4-token-jwt)

```
    $myusername = 'testingkey';
    $cek = $auth->auth(METHOD::TOKEN, function($username) {
        if ($username == $myusername) {
            return true
        } else {
            return false;
        }
    });
```

Development
-----------

[](#development)

Want to contribute? Great!

Open your favorite Terminal and run these commands.

First Tab:

```
git clone git@github.com:gunantos/PHP_AUTHENTICATION.git
```

Second Tab:

```
cd PHP_AUTHENTICATION
composer install
```

License
-------

[](#license)

MIT

Sponsor
=======

[](#sponsor)

[Pay Coffe](https://github.com/sponsors/gunantos)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

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

Recently: every ~107 days

Total

10

Last Release

1342d ago

Major Versions

0.1.1 → 1.2.02021-05-25

1.2.4 → 2.0.02022-02-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/260e9af2937309dfdeb236c6e129e26f924d1f7261a05b5496b6c40fbace8f8a?d=identicon)[Gunanto](/maintainers/Gunanto)

---

Top Contributors

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

---

Tags

apiapi-keyauthauthenticationauthorizationbasicbasic-authdigestdigest-authenticationfacebook-logingooglejwtjwt-authenticationoauthphpphpjwtauthAuthenticationbasicdigestFacebook loginGoogle login

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/appkita-phpauth/health.svg)

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

###  Alternatives

[auth0/auth0-php

PHP SDK for Auth0 Authentication and Management APIs.

40820.2M68](/packages/auth0-auth0-php)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

120220.7k1](/packages/ellaisys-aws-cognito)[kinde-oss/kinde-auth-php

Kinde PHP SDK for authentication

2369.5k3](/packages/kinde-oss-kinde-auth-php)[maicol07/flarum-ext-sso

SSO for Flarum

468.3k](/packages/maicol07-flarum-ext-sso)[benbjurstrom/cognito-jwt-guard

A laravel auth guard for JSON Web Tokens issued by Amazon AWS Cognito

1113.1k](/packages/benbjurstrom-cognito-jwt-guard)[swoft/auth

Auth component for swoft

127.2k1](/packages/swoft-auth)

PHPackages © 2026

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