PHPackages                             lovenery/lightopenid - 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. lovenery/lightopenid

ActiveLibrary

lovenery/lightopenid
====================

1.3.1(9y ago)029MITPHP

Since Jul 18Pushed 9y ago1 watchersCompare

[ Source](https://github.com/lovenery/LightOpenID)[ Packagist](https://packagist.org/packages/lovenery/lightopenid)[ Docs](https://github.com/lovenery/LightOpenID)[ RSS](/packages/lovenery-lightopenid/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

I fork form
and translate it readability for chinese users

LightOpenID
===========

[](#lightopenid)

輕量的OpenID認證library(PHP5)

- `版本:` [**1.3.1** ⏬](https://github.com/lovenery/LightOpenID/archive/master.zip) ( *看 [原作者的改版日誌](https://github.com/iignatov/LightOpenID/blob/master/CHANGELOG.md) 更詳細* )
- `發佈於:` 2016年 3月4號
- `作者的原始碼:` [Official GitHub Repo ![:octocat:](https://github.githubassets.com/images/icons/emoji/octocat.png ":octocat:")](https://github.com/Mewp/lightopenid)
- `作者:` [Mewp](https://github.com/Mewp)

快速開始
----

[](#快速開始)

### 加到 composer.json

[](#加到-composerjson)

`composer require lovenery/lightopenid`

或

```
"repositories": [
  {
    "type": "vcs",
    "url": "https://github.com/lovenery/LightOpenID"
  }
],

"require": {
  "php": ">=5.4.0",
  "lovenery/lightopenid": "1.3.1"
}
```

### 兩個步驟 登入 OpenID :

[](#兩個步驟-登入-openid-)

1. (Authentication)認證使用provider:

    ```
    $openid = new LightOpenID('my-host.example.org');

    $openid->identity = 'ID supplied by user';

    header('Location: ' . $openid->authUrl());
    ```

    The provider then sends various parameters via GET, one of which is `openid_mode`.
2. (Verification)驗證是否成功:

    ```
    $openid = new LightOpenID('my-host.example.org');

    if ($openid->mode) {
      echo $openid->validate() ? 'Logged in.' : 'Failed!';
    }
    ```

### 註:

[](#註)

變更 'my-host.example.org' 變更成你的 domain name. 不要用 `$_SERVER['HTTP_HOST']`除非你知道自己在幹麻

選擇性地, 你可以設定 `$returnUrl` 和 `$realm` (或 `$trustRoot`, which is an alias). 程式的初始值是以下:

```
$openid->realm = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
$openid->returnUrl = $openid->realm . $_SERVER['REQUEST_URI'];
```

### 也支援 AX and SREG extensions:

[](#也支援-ax-and-sreg-extensions)

在呼叫 `$openid->authUrl()` 之前, 只需要設定 `$openid->required` and/or `$openid->optional`
裡面都是放array,內容是 AX schema paths (path是網址的一部份). 例如:

```
$openid->required = array('namePerson/friendly', 'contact/email');
$openid->optional = array('namePerson/first');
```

取得你要得數值:

```
$openid->getAttributes();
```

基本設定選項詳細(可略):
-------------

[](#基本設定選項詳細可略)

   名字 詳細   identity  Sets (or gets) the identity supplied by an user. Set it before calling authUrl(), and get after validate().    returnUrl  Users will be redirected to this url after they complete authentication with their provider. Default: current url.    realm  The realm user is signing into. Providers usually say "You are sgning into $realm". Must be in the same domain as returnUrl. Usually, this should be the host part of your site's url. And that's the default.    required and optional  Attempts to fetch more information about an user. See [Common AX attributes](#common-ax-attributes).    verify\_peer  When using https, attempts to verify peer's certificate. See [CURLOPT\_SSL\_VERIFYPEER](http://php.net/manual/en/function.curl-setopt.php).    cainfo and capath  When verify\_peer is true, sets the CA info file and directory. See [CURLOPT\_SSL\_CAINFO](http://php.net/manual/en/function.curl-setopt.php) and [CURLOPT\_SSL\_CAPATH](http://php.net/manual/en/function.curl-setopt.php).   ### Common AX attributes (可略)

[](#common-ax-attributes-可略)

```
Here is a list of the more common AX attributes (from [axschema.org](http://www.axschema.org/types/)):

Name                    | Meaning
------------------------|---------------
namePerson/friendly     | Alias/Username
contact/email           | Email
namePerson              | Full name
birthDate               | Birth date
person/gender           | Gender
contact/postalCode/home | Postal code
contact/country/home    | Country
pref/language           | Language
pref/timezone           | Time zone

Note that even if you mark some field as required, there is no guarantee that you'll get any
information from a provider. Not all providers support all of these attributes, and some don't
support these extensions at all.

Google, for example, completely ignores optional parameters, and for the required ones, it supports,
according to [it's website](http://code.google.com/apis/accounts/docs/OpenID.html):

* namePerson/first (first name)
* namePerson/last (last name)
* contact/country/home
* contact/email
* pref/language

```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 81.5% 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

Unknown

Total

1

Last Release

3587d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/80c8b1f92d9c736563721e06aae748646ecdc12de9273ebf2574e99ea2f701f0?d=identicon)[lovenery](/maintainers/lovenery)

---

Top Contributors

[![iignatov](https://avatars.githubusercontent.com/u/820242?v=4)](https://github.com/iignatov "iignatov (44 commits)")[![lovenery](https://avatars.githubusercontent.com/u/11704256?v=4)](https://github.com/lovenery "lovenery (5 commits)")[![nhnb](https://avatars.githubusercontent.com/u/364184?v=4)](https://github.com/nhnb "nhnb (1 commits)")[![russor](https://avatars.githubusercontent.com/u/2165776?v=4)](https://github.com/russor "russor (1 commits)")[![vrana](https://avatars.githubusercontent.com/u/117453?v=4)](https://github.com/vrana "vrana (1 commits)")[![matejgleza](https://avatars.githubusercontent.com/u/4979665?v=4)](https://github.com/matejgleza "matejgleza (1 commits)")[![landas](https://avatars.githubusercontent.com/u/286139?v=4)](https://github.com/landas "landas (1 commits)")

### Embed Badge

![Health badge](/badges/lovenery-lightopenid/health.svg)

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

PHPackages © 2026

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