Community程式設計與開發github.com

Taldres/laravel-waitlist

在 Laravel 應用程式中整合 taldres/laravel-waitlist:定義目的、清單和欄位、建立註冊表單、從事件發送確認郵件、新增偏好設定頁面,並保留同意、保留和加密功能。

laravel-waitlist 是什麼?

此技能詳細說明如何在 Laravel 應用程式中整合 `taldres/laravel-waitlist` 套件,用於管理等待清單、搶先體驗或發布通知。它涵蓋了從安裝、定義目的和清單、建立註冊表單、處理確認郵件,到實現偏好設定頁面和資料主體權利請求的完整工作流程。此技能強調技術性隱私控制,包括同意記錄、雙重選擇加入、資料加密和保留政策,確保符合現代資料保護標準。它支援 Laravel 13 及 PHP 8.3+,並提供清晰的步驟來設定路由、限制速率、處理多語言措辭,以及透過事件監聽器自訂郵件發送。此外,該技能還指導如何處理多個專案、擴充套件點以及資料庫模型,是開發人員在 Laravel 中建立安全且合規的等待清單系統的完整指南。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Taldres/laravel-waitlist/tree/HEAD/resources/boost/skills/laravel-waitlist-development

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Laravel Waitlist

當 Laravel 應用程式需要透過 taldres/laravel-waitlist 收集等待清單、搶先體驗或發布通知的電子郵件地址時,請使用此技能。

主要目標

  • 以最小且正確的方式套用套件的公開 API,保留其技術性隱私控制:同意記錄、雙重選擇加入、加密、保留

工作流程

1. 安裝

需要 PHP 8.3+ 和 Laravel 13。

composer require taldres/laravel-waitlist
php artisan waitlist:install   # 提供者、設定和遷移;註冊提供者
php artisan migrate

waitlist:install 會發佈 app/Providers/WaitlistServiceProvider.php (waitlist-provider)、config/waitlist.php (waitlist-config) 和遷移檔 (waitlist-migrations)。必須執行 Laravel 的排程器:該套件會自行排程 waitlist:prune。

2. 定義目的、清單、欄位和頁面

在已發佈的提供者的 boot() 方法中描述等待清單;config/waitlist.php 只保留技術設定。

// app/Providers/WaitlistServiceProvider.php
use Taldres\Waitlist\Definitions\ProjectDefinition;
use Taldres\Waitlist\Facades\Waitlist;

Waitlist::define(function (ProjectDefinition $project): void {
    $project->purpose('waitlist', ['2026-10' => '當搶先體驗開放時,請郵件通知我。']);
    $project->purpose('newsletter', ['2026-10' => '也請寄送每月電子報給我。']);

    $project->list('default', purpose: 'waitlist')->optional('newsletter');
});
  • 每個清單只有一個必要的主要目的;其他都是可選的。
  • 只接受已定義清單的註冊;$project->list('*', purpose: ...) 涵蓋任何其他清單名稱。->doubleOptIn(false) 為某個清單關閉雙重選擇加入。
  • 透過 config() 讀取環境,絕不使用 env():當設定快取時,env() 在設定檔外部會回傳 null。回呼函式在首次需要專案時執行,再次定義專案會取代它。
  • 超過地址之外的欄位,可依專案和清單設定:$project->fields(fn () => [...]) 用於所有清單,->fields(...) 則用於特定清單(欄位 => 驗證規則;當規則是物件時可使用閉包)。HTTP 註冊只接受這些 metadata 下的欄位,並拒絕其他所有欄位,回傳 422;若沒有定義欄位,則拒絕所有 metadata。add() 信任其呼叫者:在你自己的控制器中,使用 Waitlist::for($list)->fields() 進行驗證。
  • 在一個應用程式中處理多個產品:每個產品使用一個 Waitlist::define('<key>', ...),並帶有自己的目的、清單、欄位和頁面,然後使用 Waitlist::project('<key>)->for($list)。不使用 project() 時,facade 預設只代表預設專案,而非所有專案;未知的專案會拋出 UnknownProjectException。 對於存放在資料庫中的專案,請繫結你自己的 ProjectCatalog 實作(waitlist.catalog):它為每個專案提供清單、欄位、措辭版本和前端 URL 模式。在 HTTP 層,ProjectResolver(waitlist.project_resolver)會為註冊請求選取專案,例如從可發佈的金鑰中選取;切勿將此檢查放入 routes.middleware,因為它也會保護郵件中的連結。僅用於表單的檢查(例如 CSRF 或來源檢查)應放入 routes.group_middleware.signup。
  • 每個專案的前端頁面在 $project->urls(...) 中設定:confirm、unsubscribe、manage(郵件連結,{token} 會被取代)以及 confirmed、expired、invalid、unsubscribed、erased(瀏覽器在 POST 請求後會導向的頁面)。
  • 每個群組的速率限制在 routes.limiters 中設定:signup → waitlist(基於 IP),links → waitlist-links(基於 token)。調整 routes.rate_limits,將某個群組指向你自己的 RateLimiter::for() 名稱(未定義的名稱會被拒絕),或將其設為 null。自訂的 limiter 會決定鍵值(->by())、限制、例外(Limit::none())、每個路由的規則($request->routeIs())以及回應;rate_limits 不適用於此。 切勿僅以 IP 作為 links 群組的鍵值:one-click 取消訂閱會共享郵件提供者的 IP。代表專案進行操作的呼叫者(HasWaitlistProject)是一個伺服器:它作為一個整體受到限制(rate_limits.caller_signup_per_minute),並自行限制其訪客,除非它透過 authentication.client_ip_header 指定的標頭轉發訪客的地址,這種情況下也會按訪客計數。
  • 若要更改措辭,請新增一個新的版本金鑰。切勿編輯現有版本的文字。
  • 多種語言:一個版本存放 ['en' => ..., 'zh-TW' => ...]。渲染 Waitlist::purposes($list, locale: $locale)(或 GET /waitlist/purposes?locale=),並將 {version, locale} 作為服務端提供的內容回傳;這樣的版本需要 locale。
  • 一個表單自行渲染文字副本(CMS)時,應加上 hash = 所顯示文字的 sha256 值;不匹配則回傳 422。設定 WAITLIST_REQUIRE_WORDING_HASH=true 要求每個新記錄的同意都包含 hash,但保留或撤回同意時不需要。
  • 在前端或 CMS 中撰寫的措辭:將 waitlist.catalog 設定為 StoredWordingCatalog,並在部署時使用 php artisan waitlist:wording wording.json 註冊(purpose => version => text;如果使用 --from-definitions,則會繼承 purpose() 中的內容),或使用 Waitlist::registerWording($purpose, $version, $wording)。已註冊的文字是不可變的:任何更改都需要新的版本。
  • 由專案自己的伺服器傳送的措辭:使用 $project->wordingFromCallers();註冊時會 POST 送出 {version, locale?, text},並在伺服器上註冊一個新版本(registered_by,事件 WordingRegistered)。對於已知版本的其他文字會回傳 422;訪客傳送文字會獲得 403(閘道操作 RegisterWording)。

3. 註冊

從伺服器渲染措辭,並回傳顯示的版本:

use Taldres\Waitlist\Facades\Waitlist;

$wording = Waitlist::purposes('default'); // list<PurposeWording>: purpose, version, text, required, locale; hash()

$result = Waitlist::for('default')->add($email, ['waitlist' => '2026-10', 'newsletter' => '2026-10']);

透過 HTTP(啟用 WAITLIST_ROUTES_ENABLED=true):先 GET /waitlist/purposes?list=default,然後 POST /waitlist 並帶上 email、list 和 purposes(格式為 {purpose: version})。地址以外的欄位放在 metadata 下,且只接受專案或清單定義的欄位。當路由關閉時,所有路由都會在套用任何速率限制或 session 之前回傳 404;空的 WAITLIST_ROUTES_ENABLED= 是設定錯誤,false 則關閉路由。

4. 郵件來自你的監聽器

該套件從不發送郵件。監聽 EntrySubscribed 事件以發送確認郵件:

use Taldres\Waitlist\Events\EntrySubscribed;

public function handle(EntrySubscribed $event): void
{
    if (! $event->requiresConfirmation) {
        return;
    }

    Mail::to($event->entry->email)->send(new ConfirmWaitlist(
        confirmUrl: $event->confirmUrl,
        purposes: $event->subscription->consents,
        unsubscribeUrl: $event->unsubscribeUrl,
    ));

    // 記錄郵件參考以及同意措辭。
    Waitlist::confirmationMailed($event->subscription, 'confirm-mail@2026-10');
}
  • $event->confirmUrl 來自專案 urls() 中的 confirm 頁面,或者如果啟用了 WAITLIST_ROUTES_ENABLED=true,則來自套件的路由。如果兩者都沒有,則為 null:請在首次註冊前設定一個,否則郵件將在沒有連結的情況下發送。無法建立的連結(例如套件路由已啟用但未註冊,就像在過期的路由快取之後)會拋出 InvalidConfigurationException 並撤銷註冊或確認:不會提交任何內容,也不會觸發任何事件。
  • 之後的每封郵件都包含一個正好撤回其目的的連結:Waitlist::unsubscribeUrl($entry, 'newsletter') 和 Waitlist::listUnsubscribeHeaders($entry, 'newsletter')。
  • 佇列的監聽器應實作 ShouldBeEncrypted:payload 包含 token,對於 EntryForgotten 事件,則包含明文地址。

5. 發送前,檢查同意

發送給 recipients():僅包含目的仍有效的地址,每個地址一次,並附帶正確的連結(unsubscribeUrl()、listUnsubscribeHeaders())和同意的 locale。

Waitlist::recipients('newsletter')->each(fn (Recipient $recipient) => ...);  // 整個專案;連結會撤回該目的(如果是主要目的,則只針對該清單)
Waitlist::for('beta')->recipients()->each(...);                              // 單個清單;連結會使該清單失效
$entry->hasConsentFor('newsletter');

6. 偏好設定頁面和權利

  • 郵件只包含取消訂閱 token,只能用於移除。偏好設定頁面需要一個短暫有效的管理 token,可應要求郵寄:監聽 ManageLinkRequested 事件,並將 $event->manageUrl 發送到 $event->entry->email。 請求:POST /waitlist/manage-link 並帶上 token(取消訂閱 token)或 email,Waitlist::requestManageLink($token),Waitlist::for($list)->requestManageLink($email)。
  • 啟用路由時,頁面使用 GET /waitlist/manage/{token}、PUT .../purposes、POST .../data、POST .../unsubscribe 和 POST .../erase(附帶 {"confirm": true});連結過期後回傳 410。
  • 按需求:Waitlist::allProjects()->personalData($email)、Waitlist::allProjects()->forget($email)(所有專案;一個控制器即可)、Waitlist::for($list)->withdraw($email, $purpose),以及 Waitlist::for($list)->forgetAll()(在清單的目的完成後使用)。

規則、參考和範本

  • 事件:EntrySubscribed、EntryConfirmed、ConsentGranted、ConsentWithdrawn、EntryUnsubscribed、SubscriptionExpired、EntryForgotten、ManageLinkRequested;所有事件都在提交後觸發。
  • 設定在使用的時候讀取,當不讀取時會拒絕,並拋出一個包含鍵名的 InvalidConfigurationException。.env 接受 true/false、on/off、yes/no、1/0 和整數(05 視為 5);其他任何內容都會被拒絕,包括空的 KEY= 行:刪除該行以保留預設值。null 表示從不或關閉(double_opt_in.token_ttl、保留期限、冷卻時間、上限、限流器、retention.schedule);管理連結始終會過期。確認或管理連結的到期時間不得晚於 2038-01-19,保留期限或冷卻時間不得早於 1970 年,因此 36500 天的「永久」會被拒絕:請使用 null。永遠無法執行的 cron 表達式和含有 {} 的路由前綴也會被拒絕。
  • 離開、撤回、確認已發出的連結、刪除和清理在設定未被讀取時仍能繼續運作(例如隱私、守衛或 token 連結上的用戶端 IP 標頭、對其他清單的電子郵件正規化掃描、重新導向後的目錄、連結速率限制(預設回退到 10 和 600)):錯誤會記錄到日誌中。註冊、閘道和報告則保持嚴格。
  • 個人資料始終使用 Laravel 的 encrypted casts 進行加密。輪換 APP_KEY 時,請將舊金鑰保留在 APP_PREVIOUS_KEYS 中,然後在棄用前執行 php artisan waitlist:rekey。
  • 套件的模型遵循 Laravel 的加密器,包括 Model::encryptUsing()。僅供套件使用的金鑰應在服務提供者的 boot() 中設定:Waitlist::encryptUsing($encrypter),其中 $encrypter 為任何 Illuminate\Contracts\Encryption\Encrypter 實作。其金鑰也用於產生查詢雜湊,因此必須保持穩定。
  • 支援的擴充點:你自己的模型、帶有設定鍵的合約(catalog、url_generator、project_resolver、email_normalizer、spam_protector)、容器繫結、useWaitlist 閘道、事件和巨集。繫結的名稱必須是實作該合約的類別,或你的應用程式繫結的介面或抽象類別;合約本身和容器無法建立的類別都會被拒絕。其他公開類別(actions、SubscriptionLifecycle、 controllers、預設實作)是開放的但不保證任何穩定性,且子類別僅在套件從容器或設定解析類別時生效,而不是在使用 new 建立時。 指南:https://github.com/Taldres/laravel-waitlist/blob/main/docs/extending.md
  • php artisan waitlist:privacy 會列印用於處理記錄的事實。
  • 運營者負責合法處理、有效的同意、通知、合理的保留、基礎設施安全性和提供者協議。該套件不提供法律建議、認證或 GDPR 合規保證;請參閱 https://github.com/Taldres/laravel-waitlist/blob/main/docs/responsibility.md 和 MIT 授權條款,並受強制性法律約束。
  • 保留預設值並非法律建議。已確認的活躍條目和剩餘的報表行不會自動過期。請單獨審查備份、佇列、日誌、匯出和提供者;剩餘的活動不保證匿名。
  • waitlist:privacy 是不完整的技術清單,並非完整的 Art. 30 記錄或合規檢查。此套件不包含任何應用程式法律文字。

相關技能

此技能涵蓋整個整合過程。針對特定任務,請載入:

  • laravel-waitlist-frontend:註冊表單、確認、取消訂閱和偏好頁面、CORS、機器人檢查
  • laravel-waitlist-mail:確認、偏好連結、歡迎、發布和電子報郵件
  • laravel-waitlist-provider-sync:逐步同步 Brevo、Mailchimp、Mailcoach,雙向
  • laravel-waitlist-projects:一個應用程式中的多個產品、解析器、中央 API
  • laravel-waitlist-reporting:每日系列、總數、隨時間變化的已確認計數
  • laravel-waitlist-launch:批次邀請、發布郵件、之後清除清單
  • laravel-waitlist-privacy-operations:存取和刪除請求、保留、金鑰輪換、上線檢查
  • laravel-waitlist-testing:來自事件的 token、郵件斷言、HTTP 路由測試

範例

  • "為登陸頁面新增等待清單":使用主要目的定義一個清單,在表單中渲染 Waitlist::purposes(),使用顯示的版本呼叫 add(),然後在 EntrySubscribed 監聽器中發送確認郵件。
  • "將已確認的註冊同步到 Brevo":監聽 EntryConfirmed、ConsentGranted、ConsentWithdrawn、`EntryUnsubscribed...

Individual skills in this repo

This repo contains 13 individual skills — each has its own dedicated page.

Taldres/laravel-waitlist

Use this skill when reviewing Laravel package compatibility across composer constraints, PHP versions, Laravel versions, Testbench versions, dependency stability lanes, Windows CI, or matrix-sensitive code and workflow changes.

Taldres/laravel-waitlist

Use this skill when creating or updating the bundled Laravel Boost skill under resources/boost/skills from the package implementation and package documentation. Trigger after public APIs, commands, config, routes, views, publish tags, README content, or examples change.

Taldres/laravel-waitlist

Use this skill when preparing Laravel package releases: CHANGELOG.md updates, generated release notes, GitHub release workflows, version checks, tags, release validation, or release automation changes. Never publish autonomously.

Taldres/laravel-waitlist

Use this skill when adding Laravel package capabilities or wiring them through the service provider: commands, migrations, routes, config merges, views, translations, assets, middleware, publish tags, workbench files, or console-only behavior.

Taldres/laravel-waitlist

Use this skill when writing, editing, fixing, or reviewing package tests with Pest 4/5 and Orchestra Testbench, including TDD, feature tests, unit tests, type coverage, arch tests, workbench behavior, commands, routes, config, migrations, and publishable resources.

Taldres/laravel-waitlist

Build the pages of a taldres/laravel-waitlist integration: the signup form with the registered wording, and the confirm, unsubscribe and preference pages, either in Laravel controllers (Blade, Livewire, Inertia) or in an SPA or static site over the package's JSON API, including CORS and bot protection.

Taldres/laravel-waitlist

Turn a taldres/laravel-waitlist waitlist into a launch: invite people in batches in signup order, let invited addresses register, announce the launch to everyone who agreed, and erase the list once its purpose is fulfilled.

Taldres/laravel-waitlist

Send the mails of a taldres/laravel-waitlist integration: the double opt-in confirmation, the preference page link, a welcome mail, launch mails and newsletters to the people who agreed, with the right unsubscribe links, one-click headers and a sender per project.

Taldres/laravel-waitlist

Operate a taldres/laravel-waitlist installation: answer access and erasure requests, withdraw a purpose on request, apply retention, erase a list once its purpose is fulfilled, rotate APP_KEY with waitlist:rekey, export a list, and check the setup before going live.

Taldres/laravel-waitlist

Run the waitlists of several products in one Laravel app with taldres/laravel-waitlist projects: define projects, scope facade calls with project(), resolve the project of HTTP signups, send mail per project, handle requests across all projects, or keep projects in a database for a central waitlist API.

Taldres/laravel-waitlist

Keep a newsletter tool such as Brevo, Mailchimp or Mailcoach in step with a taldres/laravel-waitlist waitlist: add confirmed contacts per purpose, remove them on withdrawal and erasure, and carry unsubscribes made at the provider back into the waitlist via a webhook.

Taldres/laravel-waitlist

Build waitlist statistics with taldres/laravel-waitlist: signups and confirmations per day for charts, totals and confirmation rates for a period, the confirmed count on any past day, and how many people are on a list right now, for dashboards, admin pages and API endpoints.

Taldres/laravel-waitlist

Write feature tests for an application's taldres/laravel-waitlist integration: get the plain tokens from events, assert the confirmation and other mails, test the signup, confirm and unsubscribe flows in PHP and over the package's HTTP routes, and bypass rate limits and bot checks in tests.

相關技能