lifeboat / silverstripe
Lifeboat PHP SDK - Silverstripe 包装器
dev-main
2023-04-03 12:55 UTC
Requires
- php: ^7.2 || ^8.0
- lifeboat/php-sdk: dev-main
- silverstripe/config: ~1.2.0@stable
- silverstripe/framework: ^4.9.0@stable
- silverstripe/mimevalidator: ~2.2.0@stable
Requires (Dev)
- phpunit/phpunit: ~8
This package is auto-updated.
Last update: 2024-09-03 15:54:21 UTC
README
一个简单的Lifeboat PHP SDK包装器
此包装器提供访问2个类,您的应用可以从中扩展以轻松创建Lifeboat应用。它还直接从您的环境变量中加载APP_ID
和APP_SECRET
。
安装
您可以通过Composer安装此模块。运行以下命令
composer require lifeboat/silverstripe
配置
.env
LIFEBOAT_APP_ID='[[Your App ID goes here]]' LIFEBOAT_APP_SECRET='[[Your App Secret goes here]]'
或者创建一个.yml
配置文件
lifeboat.yml
--- Name: lifeboat_config After: - '#lifeboat_silverstripe_app' --- Lifeboat\Models\Site: APP_ID: "[[YOUR APP ID]]" APP_SECRET: "[[YOUR APP SECRET]]" ---
辅助类
Lifeboat\Models\Site
// Get the current active site object Lifeboat\Models\Site::curr();
此对象将自动存储用户的当前网站,并允许自动过滤对象,以便仅显示用户有权访问的对象。
Lifeboat\Controllers\AppController
class YourController extends Lifeboat\Controllers\AppController {}
通过扩展AppController
类,您将确保与您的应用交互的任何人都已认证,并正在使用正确的网站对象。
Lifeboat\Extensions\SiteObject
YourObject: extensions: - Lifeboat\Extensions\SiteObject
确保将SiteObject
扩展添加到您的数据模型中。这将添加一个Site
关系,并自动通过augmentSQL
根据当前活动的网站过滤对象。