cosmos-cms / cosmos-php
适用于CosMoS的PHP SDK,通用的内容管理系统。
dev-master
2018-04-27 17:26 UTC
Requires
- php: >=5.4.0
- ext-openssl: *
- lib-openssl: *
This package is not auto-updated.
Last update: 2024-09-28 19:47:33 UTC
README
这个库仍在beta测试阶段,就像cosmos-cms.com一样。cosmos-cms.com.
使用这个库,从强化的内容管理系统CosMoS中检索和解密内容变得极其简单。有关详细文档,请访问:cosmos-cms.com/docs
安装
CosMoS使用Composer来管理其依赖项。
composer require "cosmos-cms/cosmos-php"
设置
您的init.php
文件。
<?php // Require the autoload.php file that's generated by Composer require 'vendor/autoload.php'; // Use the correct namespace for CosMoS use Cosmos\Cosmos; // Create a new instance of the Cosmos object $cosmos = new Cosmos(); // Setup the path to your private key // This key was only displayed once when your Application was created $cosmos->setPrivateKey('key.txt'); // Set your API key, which can be found in your Application Settings $cosmos->setApiKey("9d25d2d0053b22fdfa1b4becdfdfa9a4"); // Give up the path for the folder where your cache files will be stored $cosmos->setCachePath('cache'); // You can set a custom refresh rate in seconds, default is 1 day $cosmos->setRefreshRate(60);
使用方法
<?php // Require your bootstrap or init file require 'init.php'; // Display your content // In this case the content with API name 'welcome' is fetched from the API or cache echo $cosmos->get('welcome'); // Display your content's title or type echo $cosmos->get('welcome')->name(); echo $cosmos->get('welcome')->type(); // Returns either 'html' or 'plain'