Download the PHP package deadmantfa/yii2-oauth2-server without Composer

On this page you can find all versions of the php package deadmantfa/yii2-oauth2-server. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-oauth2-server

Yii2 OAuth2 Server (PHP 8+ & League v9 Ready)

This is a fork of the original chervand/yii2-oauth2-server plugin, updated for PHP 8+, league/oauth2-server ^9.1, and additional custom grants (including optional support for MAC tokens, token revocation, and more).

It provides:

1. Installation

Add this package to your project:

1.1 Apply DB Migrations

Run:

This creates the default OAuth2-related tables (clients, tokens, scopes, etc.).

1.2 Generate Public & Private Keys

Follow League’s official instructions for generating private/public keys. Typically:

Store them somewhere safe (e.g. @app/oauth2/private.key, @app/oauth2/public.key).

2. Basic Configuration

Below is a simple example of how to configure the module in your config/main.php (or similar file).

That’s enough to spin up the Authorization Server portion. You’ll have endpoints like:

3. Integrating with Your user Component

3.1 Provide a

In League OAuth2, you need a repository that implements . Typically, you can have your user model implement and provide a method:

3.2 Linking to Your Identity in Yii2

If you want to unify your “OAuth2 user ID” with your standard Yii user identity:

  1. In , set in your user component.
  2. Ensure your model has returning the correct user identifier.
  3. Make sure the above repository uses that same model.

4. Resource Server (Protecting Your API)

To validate tokens in your controllers, attach an authenticator that checks the header. For example:

Any requests with an invalid or no token get a 401 response.

5. MAC Tokens (Optional)

If you want MAC tokens (still a draft), you can enable them by adding:

And in your module’s , you can enable a instead of .

6. Revoke Tokens (RFC7009)

Add the in :

Then request:

The plugin revokes tokens in the DB. The next time the resource server checks that token, it’s marked invalid.

7. Optional CORS Support

If you want to handle CORS within this plugin (e.g. for /oauth2/token calls in front-end apps), you can either:

7.1 Sample Global CORS

In your main :

7.2 Built-in CORS in Module

If you want the plugin to handle it internally, you can define a property like:

8. Additional Notes


All versions of yii2-oauth2-server with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
yiisoft/yii2 Version ^2.0
league/oauth2-server Version ^9.1
guzzlehttp/guzzle Version ^7.0
lcobucci/jwt Version ^5.4.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package deadmantfa/yii2-oauth2-server contains the following files

Loading the files please wait ...