PHPackages                             kly/onesdk - 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. kly/onesdk

ActiveLibrary

kly/onesdk
==========

One SDK Publisher php package

2.3.43(1y ago)214.0k9[7 issues](https://github.com/KLYgarage/onesdk/issues)1MITPHPCI failing

Since Jun 29Pushed 1y ago2 watchersCompare

[ Source](https://github.com/KLYgarage/onesdk)[ Packagist](https://packagist.org/packages/kly/onesdk)[ RSS](/packages/kly-onesdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (70)Used By (1)

One.co.id PHP SDK
=================

[](#onecoid-php-sdk)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/deb0d8bad79a794a5f0816bdb06534b664334116551cc31c67a6e9f9c75543af/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4b4c596761726167652f6f6e6573646b2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/KLYgarage/onesdk/?branch=master)[![Build Status](https://camo.githubusercontent.com/10ed0e9c357f0557e6c13a09b57f0c0ad2fe1763fde3f4741b0e098c0d20f9f7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4b4c596761726167652f6f6e6573646b2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/KLYgarage/onesdk/build-status/master)[![Code Intelligence Status](https://camo.githubusercontent.com/220d5150a298cfad414f22ec23e25d440bcc24893d9dd773167cfef580a9f58f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4b4c596761726167652f6f6e6573646b2f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)

This SDK is created for easier intergration and API usage of ONE APP.

**For publisher only**

Prerequisite
------------

[](#prerequisite)

- PHP Version &gt;=5.3.3

Installation
------------

[](#installation)

If you are using composer you could get it with `composer require kly/onesdk` and you are all set. Load up the autoloader and Call the classes or factory you need.

Usage
-----

[](#usage)

To use this SDK, there are several basic steps that should be done :

1. Create and load credentials (client\_id and client\_secret or separated *one use* access\_token)
2. Instance your content into `\One\Model\Article` object
3. Attach any necessary details (Photos, Videos, Galleries, Or extra Pages)
4. Instance `\One\Publisher` Object
5. Send your Article object through `submitArticle` method on `Publisher`

These are some examples code to perform those steps :

### Load credentials

[](#load-credentials)

Refer to [loadTestEnv()](https://github.com/KLYgarage/onesdk/blob/master/test/bootstrap.php) method.

### Instance publisher object

[](#instance-publisher-object)

```
$env = \loadTestEnv();
        $this->publisher = new Publisher(
            $env['YOUR_CLIENT_ID'],
            $env['YOUR_CLIENT_SECRET']
        );

```

Publish
-------

[](#publish)

If you want to publish an article, there are several steps should be done :

1. Instance article object

```
$article = new Article(
            'Eius ad odit voluptatum occaecati ducimus rerum.',
            'Facilis occaecati sequi animi corrupti. Ex sit voluptates accusamus. Quidem eum magnam veniam odio totam aut. Nobis possimus totam quasi tempora consectetur iste. Repellendus est veritatis quibusdam dicta. Sapiente modi perferendis quidem repudiandae voluptates.',
            'https://www.zahn.de/home/',
            'dummy-' . rand(0, 999),
            Article::TYPE_TEXT,
            Article::CATEGORY_BISNIS,
            "Hans-Friedrich Hettner B.Sc.",
            "Dolorum expedita repellendus ipsam. Omnis cupiditate enim. Itaque alias doloribus eligendi.",
            "distinctio",
            "2013-05-25"
        );

```

2. Attach if article contains some attachments

Article supports multiple kind of attachment such as: photo, page.

```
$photo = new Photo(
            'https://aubry.fr/',
            Photo::RATIO_RECTANGLE,
            "Rerum asperiores nulla suscipit ex. Eligendi vero optio architecto dignissimos. Omnis autem ab ad hic quaerat omnis.",
            "Eum assumenda ab accusamus quam blanditiis."
        );
$article->attachPhoto($photo);

```

3. Publish the article to ONE App REST API by submitting through instanced publisher object.

`$this->publisher->submitArticle($article);`

Fetch
-----

[](#fetch)

You can fetch all the articles by calling `listArticle()` on publisher object.

`$this->publisher->listArticle();`

Steps to contribute :
---------------------

[](#steps-to-contribute-)

1. Fork the original repository to your github repository.
2. Clone from your repository

    `git clone https://github.com/your_username/onesdk.git`
3. To keep up to date with original repository, run this command

    `git remote add upstream https://github.com/KLYgarage/onesdk.git`

    `git pull upstream master`
4. Create branch. **Remember, the name of branch should express what you're doing.**

    `git checkout -b my-topic-branch`
5. Don't forget to install composer dependencies

    `composer install`
6. Modify the .env.example file, to reflect correct credentials.

    ```
    CLIENT_ID=$CLIENT_ID

    CLIENT_SECRET=$CLIENT_SECRET

    To get ACCESS_TOKEN, run the following commands using curl :

    curl -X POST "https://dev.one.co.id/oauth/token" \
     -H "Accept: application/json" \
     -d "grant_type"="client_credentials" \
     -d "client_id"="YOUR CLIENT ID" \
     -d "client_secret"="YOUR CLIENT SECRET";

    ```
7. Save the .env.example as .env
8. When you are ready to propose changes to the original repository, it's time to create pull request. To create pull request, run the following commands :

    `git push -u origin my-topic-branch`
9. Go to your github account, on tab pull request, add your comment. Be detailed, use imperative, emoticon to make it clearer.
10. Watch for feedbacks.

PHP CS Fixer
------------

[](#php-cs-fixer)

PHP CS Fixer is intended to fix coding standard. So, **Remember!** to always run PHP CS Fixer before you create pull request.

`composer run cs-fix`

Testing
-------

[](#testing)

### How to Run Tests

[](#how-to-run-tests)

Open a command prompt or terminal, navigate to project directory and run command `composer run test`

```
> php ./phpunit --bootstrap ./test/bootstrap.php ./test/
PHPUnit 4.8.36 by Sebastian Bergmann and contributors.

..................

Time: 14 seconds, Memory: 10.00MB

OK (18 tests, 98 assertions)

```

To see what test is running you can use command `composer run test:verbose`

```
> php ./phpunit --bootstrap ./test/bootstrap.php ./test/
PHPUnit 4.8.36 by Sebastian Bergmann and contributors.

Starting test 'One\Test\Unit\PublisherTest::testSubmitArticleWithoutAttachment'.
.
Starting test 'One\Test\Unit\PublisherTest::testSubmitArticleWithPhotos'.
.
Starting test 'One\Test\Unit\PublisherTest::testSubmitArticleWithPage'.
.
Starting test 'One\Test\Unit\PublisherTest::testSubmitArticleWithGallery'.
.
Starting test 'One\Test\Unit\PublisherTest::testSubmitArticleWithVideo'.

Time: 12.34 seconds, Memory: 10.00MB

OK (18 tests, 98 assertions)

```

### What to Remember When Writing a Test

[](#what-to-remember-when-writing-a-test)

1. Make sure to create test case for every core function on the class.
2. Always compare data you expected or created before you make a request with the actual data that you get from a response.
3. Use the correct assertion. Avoid using assertEquals to compare arrays because sometimes you will get array (response from server) values sorted in different order from your expected array. In example:

```
$array = [
  '0'=>'500',
  '1'=>'A'
];

$arrayFromResponse = [
  '0'=>'A',
  '1'=>'500
];

```

Rather than sorting `$arrayFromResponse` to make the order equal, we can use `assertTrue` combine with `array_diff`

```
assertTrue(empty(array_diff($array, $arrayFromResponse)));

```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance21

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Every ~35 days

Total

68

Last Release

487d ago

Major Versions

1.3.2 → 2.3.32019-01-08

1.3.3 → 2.3.42019-01-09

1.3.5 → 2.3.52019-01-18

1.3.6 → 2.3.72019-01-24

1.3.7 → 2.3.82019-04-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/db58733273be2fe9b927dcd59c65900fba5e1fff6c272a4ae876438096703617?d=identicon)[kly](/maintainers/kly)

---

Top Contributors

[![charsme](https://avatars.githubusercontent.com/u/1236083?v=4)](https://github.com/charsme "charsme (43 commits)")[![budikhafiKLY](https://avatars.githubusercontent.com/u/37651137?v=4)](https://github.com/budikhafiKLY "budikhafiKLY (27 commits)")[![kennykarnama](https://avatars.githubusercontent.com/u/26187880?v=4)](https://github.com/kennykarnama "kennykarnama (10 commits)")[![dentamuhajir-lgtm](https://avatars.githubusercontent.com/u/243168055?v=4)](https://github.com/dentamuhajir-lgtm "dentamuhajir-lgtm (6 commits)")[![martinocatur](https://avatars.githubusercontent.com/u/23295412?v=4)](https://github.com/martinocatur "martinocatur (4 commits)")[![setiawanYusuf](https://avatars.githubusercontent.com/u/40681118?v=4)](https://github.com/setiawanYusuf "setiawanYusuf (4 commits)")[![dentamuhajir](https://avatars.githubusercontent.com/u/39980668?v=4)](https://github.com/dentamuhajir "dentamuhajir (2 commits)")[![kmkonline](https://avatars.githubusercontent.com/u/5456897?v=4)](https://github.com/kmkonline "kmkonline (1 commits)")

---

Tags

php-sdksdk

###  Code Quality

TestsPHPUnit

Code StyleECS

### Embed Badge

![Health badge](/badges/kly-onesdk/health.svg)

```
[![Health](https://phpackages.com/badges/kly-onesdk/health.svg)](https://phpackages.com/packages/kly-onesdk)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[aporat/store-receipt-validator

PHP receipt validator for Apple App Store and Amazon Appstore

6503.9M9](/packages/aporat-store-receipt-validator)[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k20](/packages/neuron-core-neuron-ai)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)

PHPackages © 2026

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