Skip to content

Commit 4b75397

Browse files
committed
Removed installation steps and link to the docs
1 parent c62ae29 commit 4b75397

File tree

1 file changed

+9
-89
lines changed

1 file changed

+9
-89
lines changed

README.md

Lines changed: 9 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Auth0 PHP SDK
22

3+
## Installation
4+
5+
Check our docs page to get a complete guide on how to install it in an existing project or download a pre configured seedproject:
6+
7+
* Regular webapp: https://auth0.com/docs/quickstart/webapp/php/
8+
* Web API: https://auth0.com/docs/quickstart/backend/php/
9+
10+
> If you find something wrong in our docs, PR are welcome in our docs repo: https://github.com/auth0/docs
11+
312
## News
413

514
The version 1.x of the PHP SDK now works with the Auth API v2 which adds lots of new [features and changes](https://auth0.com/docs/apiv2Changes).
@@ -55,95 +64,6 @@ $ php -S localhost:3000
5564
3. Now the SDK is PSR-4 compliant so you will need to change the namespaces (sorry **:(** ) to `\Auth0\SDK`
5665
4. The method `getUserInfo` is deprecated and candidate to be removed on the next release. User `getUser` instead. `getUser` returns an User object compliant with API v2 which is a `stdClass` (check the schema [here](https://auth0.com/docs/apiv2#!/users/get_users_by_id))
5766

58-
## Installation
59-
60-
### 1. Install the SDK
61-
62-
We recommend using [Composer](http://getcomposer.org/doc/01-basic-usage.md) to install the library.
63-
64-
To install, run `composer require auth0/auth0-php:"~1.0"`.
65-
66-
### 2. Setup the callback action
67-
Create a php page (or action if you are using an MVC framework) that will handle the callback from the login attempt.
68-
69-
In there, you should create an instance of the SDK with the proper configuration and ask for the user information.
70-
71-
~~~php
72-
use Auth0\SDK\Auth0;
73-
74-
$auth0 = new Auth0(array(
75-
'domain' => 'YOUR_AUTH0_DOMAIN',
76-
'client_id' => 'YOUR_AUTH0_CLIENT_ID',
77-
'client_secret' => 'YOUR_AUTH0_CLIENT_SECRET',
78-
'redirect_uri' => 'http://<name>/callback.php'
79-
));
80-
81-
$userInfo = $auth0->getUser();
82-
~~~
83-
84-
If the user was already logged in, `getUser()` will retrieve that [user information](https://docs.auth0.com/user-profile) from the `PHP Session`. If not, it will try to exchange the code given to the callback to get an access token, id token and the [user information](https://docs.auth0.com/user-profile) from auth0.
85-
86-
This makes it possible to use the same code in the callback action and any other page, so to see if there is a logged in user, you can call
87-
88-
89-
~~~php
90-
// ...
91-
// code from above
92-
93-
if (!$userInfo) {
94-
// print login button
95-
} else {
96-
// Say hello to $userInfo['name']
97-
// print logout button
98-
}
99-
~~~
100-
101-
### 3. Setup the callback action in Auth0
102-
103-
After authenticating the user on Auth0, we will do a GET to a URL on your web site. For security purposes, you have to register this URL on the Application Settings section on Auth0 Admin app.
104-
105-
http://<name>/callback.php
106-
107-
108-
### 4. Triggering login manually or integrating the Auth0 widget
109-
110-
You can trigger the login in different ways, like redirecting to a login link or using [Lock](https://docs.auth0.com/lock), by adding the following javascript into your page
111-
112-
~~~html
113-
<button onclick="login()">Login</button>
114-
115-
<script src="https://cdn.auth0.com/js/lock-7.min.js"></script>
116-
<script type="text/javascript">
117-
var lock = new Auth0Lock(AUTH0_CLIENT_ID, AUTH0_DOMAIN);
118-
119-
function login() {
120-
lock.show({
121-
callbackURL: AUTH0_CALLBACK_URL
122-
, responseType: 'code'
123-
, authParams: {
124-
scope: 'openid name email picture'
125-
}
126-
});
127-
}
128-
</script>
129-
~~~
130-
131-
### 5. (Optional) Configure session data
132-
133-
By default, the SDK will store the [user information](https://docs.auth0.com/user-profile) in the `PHP Session` and it will discard the access token and the id token. If you like to persist them as well, you can pass `'persist_access_token' => true` and `'persist_id_token' => true` to the SDK configuration in step 2. You can also disable session all together by passing `'store' => false`.
134-
135-
If you want to change `PHP Session` and use Laravel, Zend, Symfony or other abstraction to the session, you can create a class that implements `get`, `set`, `delete` and pass it to the SDK as following.
136-
137-
~~~php
138-
$laravelStore = new MyLaravelStore();
139-
$auth0 = new Auth0(array(
140-
// ...
141-
'store' => $laravelStore,
142-
// ...
143-
));
144-
~~~
145-
146-
14767
## Develop
14868

14969
This SDK uses [Composer](http://getcomposer.org/doc/01-basic-usage.md) to manage its dependencies.

0 commit comments

Comments
 (0)