cthomas87/scorm-cloud-laravel

为Laravel应用程序提供ScormCloud API网关

v0.0.2 2017-11-28 21:05 UTC

This package is not auto-updated.

Last update: 2024-09-25 19:06:50 UTC


README

为Laravel应用程序提供ScormCloud API网关。

需求

此包可在Laravel 5.4或更高版本中使用。

安装

此库可以通过Composer使用 通过Composer

命令行

composer require asifm42/scorm-cloud-laravel

Composer.json

{
    "require": {
        "asifm42/scorm-cloud-laravel": "dev-master"
    }
}

Laravel 5.5中,服务提供程序将自动注册。在框架的旧版本中,只需在config/app.php文件中添加服务提供程序即可

'providers' => [
    // ...
    AsifM42\ScormCloudGateway\ScormCloudServiceProvider::class,
];

配置

您可以通过发布配置文件或添加适当的环境变量来配置您的凭证。

环境变量
  • SCORMCLOUD_URL - 此属性是以前Rustici ScormCloud产品迭代的一个遗迹。它很可能不需要被覆盖。但它在无法支持HTTPS等情况下存在。(默认: "https://cloud.scorm.com/EngineWebServices")

  • SCORMCLOUD_APPID - 应用ID(必需)

  • SCORMCLOUD_KEY - 与应用ID关联的秘密密钥(必需)

  • SCORMCLOUD_ORGANIZATION - 与应用关联的组织名称(默认: "scl")

  • SCORMCLOUD_APP_NAME - 应用名称(默认: "app")

  • SCORMCLOUD_VERSION - 版本号(默认: "1.0")

组织名称、应用名称和版本号用于创建源字符串。源字符串对于在SCORM Cloud开发者方面的调试很有用,但不是必需的。默认字符串将是 "scl.app.1.0"。

您可以使用以下命令发布配置文件

php artisan vendor:publish --provider="AsifM42\ScormCloudGateway\ScormCloudServiceProvider" --tag="config"

发布后,config/scormcloud.php配置文件包含

return [

    /**
     * The scorm engine service url.
     *
     * This attribute is a relic of a previous Rustici ScormCloud product
     * iteration. It will most likely not need to be overriden. But its
     * there for instances such as when HTTPS cannot be supported, etc.
     */
    'url' => env('SCORMCLOUD_URL', 'https://cloud.scorm.com/EngineWebServices'),

    /**
     * The application id
     *
     * Required
     */
    'app_id' => env('SCORMCLOUD_APPID', ''),

    /**
     * Any secret key associated with the app id
     *
     * Required
     */
    'key' => env('SCORMCLOUD_KEY', ''),

    /**
     * The organization name.
     *
     * This will be used to create an origin string which is useful
     * for debugging on the SCORM Cloud developers’ side
     *
     * optional
     */
    'organization' => env('SCORMCLOUD_ORGANIZATION', 'scl'),

    /**
     * The app name.
     *
     * This will be used to create an origin string which is useful
     * for debugging on the SCORM Cloud developers’ side
     *
     * optional
     */
    'app_name' => env('SCORMCLOUD_APP_NAME', 'app'),

    /**
     * The version number.
     *
     * This will be used to create an origin string which is useful
     * for debugging on the SCORM Cloud developers’ side
     *
     * optional
     */
    'version' => env('SCORMCLOUD_VERSION','1.0')
];

使用方法

您可以使用提供的辅助函数来访问网关

scormcloud()

您可以通过以下方式获取课程列表

scormcloud()->getCourses()