Skip to content
Christopher Wilkinson edited this page Jun 23, 2017 · 39 revisions

Opauth logo

Opauth is a multi-provider authentication framework for PHP.

Current version: 0.4.3

1.0 Alpha docs


Pick and choose your favorite installation method:

i. Via Composer

Composer is a dependency manager for PHP.

To install Opauth core only, include opauth/opauth to your composer.json:

        "opauth/opauth": "*"

Opauth requires strategies to work. We suggest that you add these packages as well for Facebook, Google and/or Twitter authentication support.

        "opauth/opauth": "*",
        "opauth/facebook": "*",
        "opauth/google": "*",
        "opauth/twitter": "*"

Run php composer.phar install

ii. Manual download

Download Opauth (ZIP) and unzip it.

Download additional strategies and place them in directories at path_to_opauth/Strategy.
Remember to name the directory name as the actual name of the strategy. For example, place Facebook strategy files in path_to_opauth/Strategy/Facebook so that FacebookStrategy.php can be found at path_to_opauth/Strategy/Facebook/FacebookStrategy.php.

If you prefer git clone, you can simply run the following without worrying about renaming:

cd path_to_opauth/Strategy
git clone git:// Facebook

Note: You can have Strategy/ directory anywhere in your system. All you have to do is explicitly define strategy_dir in your Opauth configuration.

iii. As plugin on other PHP frameworks

If you are using any of the following PHP frameworks, you can install Opauth as a plugin or extension. Follow the instructions at the respective packages:

Made a plugin? Edit this wiki and add yours!

Using Opauth

  1. Load Opauth configuration as an array.

  2. Instantiate Opauth by passing the configuration.

require 'path_to_opauth/Opauth.php';
$Opauth = new Opauth( $config );
  1. Direct all authentication traffic to the Opauth instance.

    You may want to use the included .htaccess in example/ for this, or via Router in your PHP framework.

    Alternatively, you can explicitly pass in a request_uri in Opauth configuration to "simulate" a request.

  2. Implement callback to expect auth response.
    Refer to example/callback.php on how you should handle auth response.

All of the above are also implemented as an example in the example/ directory for your reference.

You can’t perform that action at this time.