PHPackages                             adriengras/pkce-php - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. adriengras/pkce-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

adriengras/pkce-php
===================

A simple utility to use PKCE (Proof Key for Code Exchange) in PHP.

1.0.4(1y ago)927.7k↓14.7%11MITPHPPHP &gt;=7.4CI passing

Since Aug 25Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/AdrienGras/pkce-php)[ Packagist](https://packagist.org/packages/adriengras/pkce-php)[ RSS](/packages/adriengras-pkce-php/feed)WikiDiscussions main Synced 1mo ago

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

pkce-php
========

[](#pkce-php)

[![GitHub](https://camo.githubusercontent.com/854222808bf47514633277fa1b929925a8883a8d16877a2cc0e581c382b3a5b8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f41647269656e477261732f706b63652d706870)](https://camo.githubusercontent.com/854222808bf47514633277fa1b929925a8883a8d16877a2cc0e581c382b3a5b8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f41647269656e477261732f706b63652d706870)[![GitHub workflows](https://github.com/AdrienGras/pkce-php/actions/workflows/php.yml/badge.svg)](https://github.com/AdrienGras/pkce-php/actions/workflows/php.yml/badge.svg)

A simple utility to use PKCE (Proof Key for Code Exchange) in PHP.

This little utility is intended to help people using Oauth2 with PKCE in PHP. It provides a simple way to generate a code verifier, a code challenge and to validate a code verifier with a code challenge.

Summary
-------

[](#summary)

- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Contributors](#contributors)
- [License](#license)

Features
--------

[](#features)

- Generate a code verifier
- Generate a code challenge from a given code verifier
- Generate a pair of code verifier and code challenge
- Verify a code verifier with a code challenge

> **Note:** All the code complies to the [RFC 7636](https://tools.ietf.org/html/rfc7636).

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

[](#installation)

Using composer:

```
composer require adriengras/pkce-php
```

Usage
-----

[](#usage)

```
// import with composer autoloader
use AdrienGras\PKCE\PKCEUtils;

// ...

// generate a code verifier
$verifier = PKCEUtils::generateCodeVerifier();

// generate a code challenge from the code verifier
$challenge = PKCEUtils::generateCodeChallenge($verifier);

// you can also use the plain text challenge method for testing purpose
// WARNING: this method is not secure and should not be used in production
$challenge = PKCEUtils::generateCodeChallenge($verifier, PKCEUtils::CODE_CHALLENGE_METHOD_PLAIN);

// alternatively, generate a pair of code verifier and code challenge
$pair = PKCEUtils::generateCodePair();
$verifier = $pair['code_verifier'];
$challenge = $pair['code_challenge'];
// or with destructuring
['code_verifier' => $verifier, 'code_challenge' => $challenge] = PKCEUtils::generateCodePair();

// validate a code verifier with a code challenge
$isValid = PKCEUtils::validate($verifier, $challenge);
```

> **Note** You can also use the test case suite as a full example on how to use this utility. You can find it in the [tests](tests) folder.

Contributors
------------

[](#contributors)

- [Farkie](https://github.com/Farkie)

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance56

Moderate activity, may be stable

Popularity35

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.3% 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 ~125 days

Total

5

Last Release

496d ago

### Community

Maintainers

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

---

Top Contributors

[![AdrienGras](https://avatars.githubusercontent.com/u/72006541?v=4)](https://github.com/AdrienGras "AdrienGras (26 commits)")[![Farkie](https://avatars.githubusercontent.com/u/294921?v=4)](https://github.com/Farkie "Farkie (1 commits)")

### Embed Badge

![Health badge](/badges/adriengras-pkce-php/health.svg)

```
[![Health](https://phpackages.com/badges/adriengras-pkce-php/health.svg)](https://phpackages.com/packages/adriengras-pkce-php)
```

###  Alternatives

[calotype/seo

A package containing SEO helpers.

722.6k](/packages/calotype-seo)

PHPackages © 2026

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