Skip to content

The official PHP client for Cosmic JS. This module will help you easily add dynamic content to your website or application.

Notifications You must be signed in to change notification settings

cosmicjs/cosmicjs-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cosmic JS Logo

Getting started

Go to https://cosmicjs.com, create an account and setup a bucket.

Install

git clone https://github.com/cosmicjs/cosmicjs-php

Usage

<?php
/* !!!! CONFIGURE !!!!
==================================== */
$config = new stdClass();
$config->bucket_slug = "driver-example"; // bucket slug
$config->read_key = ""; // leave empty if not required
$config->write_key = ""; // leave empty if not required
include("cosmicjs.php");

/* Add
================================= */
$object_string = '{
  "type_slug": "pages",
  "title": "Test Title",
  "content": "here is some test content",
  "write_key": "' . $config->write_key . '"
}';
$object = $cosmicjs->addObject($object_string);

/* Edit
================================= */
$object_string = '{
  "slug": "test-title",
  "title": "New Title",
  "content": "here is some NEW test content",
  "write_key": "' . $config->write_key . '"
}';
$object = $cosmicjs->editObject($object_string);

/* Delete
================================= */
$object_string = '{
  "slug": "test-title",
  "write_key": "' . $config->write_key . '"
}';
$object = $cosmicjs->deleteObject($object_string);

/* Get Objects
================================= */
$objects = $cosmicjs->getObjects();

/* Get Media
================================= */
$media = $cosmicjs->getMedia();
?>

About

The official PHP client for Cosmic JS. This module will help you easily add dynamic content to your website or application.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages