PHPackages                             rogervila/cosmicjs-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rogervila/cosmicjs-php

ActiveLibrary[API Development](/categories/api)

rogervila/cosmicjs-php
======================

Based on https://github.com/cosmicjs/cosmicjs-php but with composer and OOP.

1.0.0(9y ago)444NonePHP

Since Nov 12Pushed 4y ago1 watchersCompare

[ Source](https://github.com/rogervila/cosmicjs-php)[ Packagist](https://packagist.org/packages/rogervila/cosmicjs-php)[ RSS](/packages/rogervila-cosmicjs-php/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

CosmicJS PHP kit
================

[](#cosmicjs-php-kit)

[![Code Climate](https://camo.githubusercontent.com/5aeda19ca9cb735a2576aeac0154f8e6e5886987f51953ac8f527c3f981bc868/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f726f67657276696c612f636f736d69636a732d7068702f6261646765732f6770612e737667)](https://codeclimate.com/github/rogervila/cosmicjs-php)[![Issue Count](https://camo.githubusercontent.com/a558a0b60b3206bfd58dc586223f2ad32371aa062afdc8dfb2d3d0ad3e928a30/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f726f67657276696c612f636f736d69636a732d7068702f6261646765732f69737375655f636f756e742e737667)](https://codeclimate.com/github/rogervila/cosmicjs-php)[![Test Coverage](https://camo.githubusercontent.com/ffb5b8a14b3e923fd5042e74843516374a1e439ba4fa148af5c107afc3e237fe/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f726f67657276696c612f636f736d69636a732d7068702f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/rogervila/cosmicjs-php/coverage)[![TravisCI Build Status](https://camo.githubusercontent.com/b7a17d7c2670e21856d17450abe59f5a3fa82d9fe8db4610c8f2e717b6c8532b/68747470733a2f2f7472617669732d63692e6f72672f726f67657276696c612f636f736d69636a732d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/rogervila/cosmicjs-php)[![StyleCI](https://camo.githubusercontent.com/233bed45dee090f1bced6fd0d3d2482ea13689147342d0b886fe87a5b32694f8/68747470733a2f2f7374796c6563692e696f2f7265706f732f36393637383234362f736869656c64)](https://styleci.io/repos/69678246)[![Latest Stable Version](https://camo.githubusercontent.com/8355044053c1bb7a24f652870c5bd4d2d66a6d5d8e2f83a6388edf84fd5110a8/68747470733a2f2f706f7365722e707567782e6f72672f726f67657276696c612f636f736d69636a732d7068702f762f737461626c65)](https://packagist.org/packages/rogervila/cosmicjs-php)[![Total Downloads](https://camo.githubusercontent.com/04803d1e43dab7e5bc9c4cc74d33c8974e99a6962b03061dad4b07be7f3ed98d/68747470733a2f2f706f7365722e707567782e6f72672f726f67657276696c612f636f736d69636a732d7068702f646f776e6c6f616473)](https://packagist.org/packages/rogervila/cosmicjs-php)[![Appveyor Build status](https://camo.githubusercontent.com/ae8efa8d2f2beb572ccfa5a23638a5e77741f0c6813f841fb4b4409e5cfbfe70/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f336b7368776f6b6b686d6878356768343f7376673d74727565)](https://ci.appveyor.com/project/roger-vila/cosmicjs-php)

Based on  but with composer and OOP.

Install
-------

[](#install)

```
$ composer require rogervila/cosmicjs-php
```

Basic setup
-----------

[](#basic-setup)

```
// Set the configuration
$config = new \Rogervila\CosmicJS\Config();

$config
    ->setBucketSlug('YOUR_BUCKET_SLUG')
    ->setWriteKey('YOUR_WRITE_KEY')
    ->setReadKey('YOUR_READ_KEY');

// Create an instance
$cosmic = new \Rogervila\CosmicJS\CosmicJS($config);

// Bucket information
$cosmic->getBucket();

// Read objects
$cosmic->getObjects();

// Read object by slug
$cosmic->getObject('OBJECT_SLUG');

// Read media
$cosmic->getMedia();

// Create an object

// object parameters
$parameters = new \Rogervila\CosmicJS\Parameters($config);
$parameters->typeSlug = 'my-object';
$parameters->title = 'My Object';

// add metafields
$meta = new \Rogervila\CosmicJS\Metafield();

$meta->key = 'field-name';
$meta->type = 'textarea';
$meta->value = 'lorem ipsum';

$parameters->metafields = [
    $meta,
];

$cosmic->addObject($parameters);

// Edit an object

// create object parameters...

$cosmic->editObject($parameters);

// Delete an object

// create object parameters...

$cosmic->editObject($parameters);
```

TODOS
-----

[](#todos)

- More tests
- Move from Curl to Guzzle

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3518d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/351443b7d23e94fcf31b250db90f0b9578cc9fd8e0cefbed9666467e3e9cb571?d=identicon)[rogervila](/maintainers/rogervila)

---

Top Contributors

[![rogervila](https://avatars.githubusercontent.com/u/6053012?v=4)](https://github.com/rogervila "rogervila (33 commits)")

---

Tags

cosmicjslibaryphpapicmscosmicjscosmicjs-php

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rogervila-cosmicjs-php/health.svg)

```
[![Health](https://phpackages.com/badges/rogervila-cosmicjs-php/health.svg)](https://phpackages.com/packages/rogervila-cosmicjs-php)
```

###  Alternatives

[craftcms/element-api

Create a JSON API for your elements in Craft

502710.4k9](/packages/craftcms-element-api)[aheinze/cockpit

Cockpit Headless CMS

5.4k2.0k4](/packages/aheinze-cockpit)[getkirby/kql

Kirby Query Language

15027.0k](/packages/getkirby-kql)[joy/voyager-api

This Laravel/Voyager module adds REST Api with swagger support to Voyager.

194.8k3](/packages/joy-voyager-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
