2017 © Pedro Peláez
 

library cosmos-php

The PHP SDK for CosMoS, the universal cms.

image

cosmos-cms/cosmos-php

The PHP SDK for CosMoS, the universal cms.

  • Friday, April 27, 2018
  • by mariusbirkhoff
  • Repository
  • 1 Watchers
  • 0 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

CosMoS' PHP Library

This library is still in beta, just like cosmos-cms.com.

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)

Instalation

CosMoS uses Composer to require its dependencies., (*2)

composer require "cosmos-cms/cosmos-php"

Setup

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);

Usage

<?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'

The Versions

27/04 2018

dev-master

9999999-dev

The PHP SDK for CosMoS, the universal cms.

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-openssl *
  • lib-openssl *