PHPackages                             tapao/line-notification - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. tapao/line-notification

ActiveFlarum-extension[Mail &amp; Notifications](/categories/mail)

tapao/line-notification
=======================

Send Flarum forum notifications to users via LINE push messages.

2.2.0(1mo ago)018MITPHP

Since Jul 4Pushed 1mo agoCompare

[ Source](https://github.com/Tapao-NonSen/LINE-Notification)[ Packagist](https://packagist.org/packages/tapao/line-notification)[ RSS](/packages/tapao-line-notification/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (4)Versions (4)Used By (0)

tapao/line-notification
=======================

[](#tapaoline-notification)

A Flarum extension that lets forum users connect their LINE account and receive forum notifications (mentions, replies, likes, subscriptions) via LINE push messages.

---

Features
--------

[](#features)

- 🟢 **LINE OAuth connect/disconnect** — users link their LINE account from Settings
- 🔔 **LINE push notifications** — mention, reply, like, new-post notifications delivered as **LINE Flex Messages**
- 🎨 **Custom branding** — rich Flex Message cards with the forum's color scheme
- ⚙️ **Admin settings** — Channel ID, Channel Secret, Messaging API Token configurable from Flarum Admin
- 🛡️ **Auto-cleanup** — if a user blocks the LINE bot, their LINE data is automatically cleared
- 🔗 **Webhook endpoint** — handles LINE unfollow/block events

---

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

[](#installation)

### For Flarum 2.x (Recommended)

[](#for-flarum-2x-recommended)

```
composer require tapao/line-notification
php flarum migrate
php flarum cache:clear
```

### For Flarum 1.x

[](#for-flarum-1x)

```
composer require tapao/line-notification:^1.1
php flarum migrate
php flarum cache:clear
```

---

Setup
-----

[](#setup)

### 1. LINE Developers Console

[](#1-line-developers-console)

Create two channels on [LINE Developers Console](https://developers.line.biz/):

Channel TypePurpose**LINE Login**OAuth flow to link user accounts**Messaging API**Push message delivery### 2. LINE Login Channel settings

[](#2-line-login-channel-settings)

- Add callback URL: `https://YOUR-FORUM-DOMAIN/api/line/callback`
- Enable: `profile` and `openid` scopes

### 3. Messaging API Channel settings

[](#3-messaging-api-channel-settings)

- Register webhook URL: `https://YOUR-FORUM-DOMAIN/api/line/webhook`
- Issue a **Long-lived Channel Access Token**

### 4. Admin panel

[](#4-admin-panel)

Go to **Admin → Extensions → LINE Notification** and enter:

- LINE Login Channel ID
- LINE Login Channel Secret
- Messaging API Channel Access Token

---

File Structure
--------------

[](#file-structure)

```
tapao/line-notification/
├── composer.json
├── extend.php                          # Extension entry point
├── migrations/
│   └── 2024_01_01_000001_add_line_fields_to_users.php
├── src/
│   ├── Api/
│   │   └── LineApiClient.php           # HTTP wrapper for LINE APIs
│   ├── Controllers/
│   │   ├── ConnectController.php       # Redirects to LINE OAuth
│   │   ├── CallbackController.php      # Handles OAuth callback
│   │   ├── DisconnectController.php    # Clears LINE user data
│   │   └── WebhookController.php      # Handles LINE webhook events
│   ├── Driver/
│   │   └── LineNotificationDriver.php  # Flarum notification driver
│   ├── Exceptions/
│   │   ├── LineUserNotFoundException.php
│   │   └── LinePushException.php       # 400 (bad payload) ≠ unlink
│   ├── Extend/
│   │   └── LineNotification.php        # ->resolver() extender for other extensions
│   ├── Formatter/
│   │   ├── FlexMessageFormatter.php    # Builds LINE Flex Messages
│   │   ├── FlexTextSanitizer.php       # Guarantees a LINE-valid payload
│   │   ├── NotificationContent.php     # DTO returned by resolvers
│   │   └── Resolver/                   # Post/Discussion/User/Generic content resolvers
│   ├── Provider/
│   │   └── LineNotificationServiceProvider.php
│   └── Listener/
│       ├── AddLineUserAttributes.php   # Exposes LINE fields to API
│       └── SaveLineUserAttributes.php
├── js/
│   ├── package.json
│   ├── webpack.config.js
│   ├── tsconfig.json
│   └── src/
│       ├── forum/
│       │   ├── index.js                # Forum entry point
│       │   └── components/
│       │       └── LineAccountSection.js  # Connect/disconnect UI
│       └── admin/
│           └── index.js                # Admin settings entry point
├── less/
│   ├── forum.less                      # Forum styles
│   └── admin.less                      # Admin styles
└── locale/
    ├── en.yml
    └── th.yml

```

---

Architecture
------------

[](#architecture)

### Notification Flow

[](#notification-flow)

```
Flarum notification event
    → Extend\Notification()->type(Blueprint, ['line'])
    → LineNotificationDriver::send($blueprint, $users)
    → FlexMessageFormatter::format($blueprint)
        → first matching ContentResolverInterface (Post → Discussion → User → your resolvers → Generic)
        → FlexTextSanitizer (never-empty text, length caps, https-only hero image)
    → LineApiClient::pushMessage($lineUserId, $messages, $token)
    → LINE Messaging API
    → User's LINE app

```

### Rendering notifications from other extensions

[](#rendering-notifications-from-other-extensions)

Out of the box, `FlexMessageFormatter` renders `Post`, `Discussion`, and `User` notification subjects, and falls back to a generic resolver for anything else (it looks for a `discussion`/`post` relation or a `title`/`name` attribute, then a "From {user}" line — so the message is never blank).

If your extension's blueprint subject needs a more specific title, excerpt, or deep link, register your own resolver:

```
// your-extension/extend.php
use Tapao\LineNotification\Extend\LineNotification;

return [
    (new LineNotification())
        ->resolver(\YourExtension\LineContentResolver::class),
];
```

```
namespace YourExtension;

use Flarum\Notification\Blueprint\BlueprintInterface;
use Tapao\LineNotification\Formatter\NotificationContent;
use Tapao\LineNotification\Formatter\Resolver\ContentResolverInterface;

class LineContentResolver implements ContentResolverInterface
{
    public function supports(BlueprintInterface $blueprint): bool
    {
        return $blueprint->getSubject() instanceof YourModel;
    }

    public function resolve(BlueprintInterface $blueprint): NotificationContent
    {
        $subject = $blueprint->getSubject();

        return new NotificationContent(
            title: $subject->title,
            excerpt: $subject->summary,
            url: '/your-route/' . $subject->id,
        );
    }
}
```

Resolvers run in registration order — built-in Post → Discussion → User first, then resolvers registered via `->resolver()` in the order extensions load, and the generic fallback last regardless of registration order. Also add a `tapao-line-notification.lib.line_message.notification_` translation key to give your notification type a custom header label — it's picked up automatically.

### OAuth Flow

[](#oauth-flow)

```
User clicks "Connect LINE" in Settings
    → GET /api/line/connect
    → ConnectController: build authorize URL with signed state
    → Redirect to LINE OAuth
    → User grants consent
    → LINE redirects to GET /api/line/callback?code=...&state=...
    → CallbackController: verify state, exchange code, fetch profile
    → Write line_user_id, line_display_name, line_linked_at to user
    → Redirect to /settings?line_linked=1

```

---

License
-------

[](#license)

MIT

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance91

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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 ~2 days

Total

3

Last Release

44d ago

Major Versions

v1.1.6 → 2.1.02026-07-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/478b1e3108f03ecd77dfab7f49c97765d5e6bcd15e73d602844b3ea0e1281407?d=identicon)[tapao](/maintainers/tapao)

---

Top Contributors

[![Tapao-NonSen](https://avatars.githubusercontent.com/u/40026698?v=4)](https://github.com/Tapao-NonSen "Tapao-NonSen (31 commits)")

---

Tags

flarumflarum-extensionpushnotificationextensionflarumline

### Embed Badge

![Health badge](/badges/tapao-line-notification/health.svg)

```
[![Health](https://phpackages.com/badges/tapao-line-notification/health.svg)](https://phpackages.com/packages/tapao-line-notification)
```

###  Alternatives

[flarum-lang/russian

Russian language pack for Flarum.

13129.1k](/packages/flarum-lang-russian)[guanguans/notify

Push notification SDK(AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NotifyX、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

691116.9k8](/packages/guanguans-notify)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)[bentools/webpush-bundle

Send push notifications through Web Push Protocol to your Symfony users.

72297.8k](/packages/bentools-webpush-bundle)[flarum-lang/french

French language pack to localize the Flarum forum software plus its official and third-party extensions.

1941.0k](/packages/flarum-lang-french)[fof/webhooks

Automatically notify Discord, Slack, and Microsoft Teams when events happen on your Flarum forum.

2420.9k](/packages/fof-webhooks)

PHPackages © 2026

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