Wallogit.com
2017 © Pedro Peláez
The PHP SDK for CosMoS, the universal cms.
Using this library it's extremely easy to fetch and decrypt your content from CosMoS, The Universal CMS. For detailed documentation, please go to: cosmos-cms.com/docs, (*1)
CosMoS uses Composer to require its dependencies., (*2)
composer require "cosmos-cms/cosmos-php"
Your init.php file., (*3)
<?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'