PHPackages                             clopri/appsdk - 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. clopri/appsdk

ActiveLibrary

clopri/appsdk
=============

Sdk de clopri app

3.4.7(3mo ago)09GPL-3.0-or-laterPHP

Since Dec 10Pushed 3mo agoCompare

[ Source](https://github.com/Clopri/appsdk)[ Packagist](https://packagist.org/packages/clopri/appsdk)[ RSS](/packages/clopri-appsdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (5)Used By (0)

**Clopri App SDK Documentation**
================================

[](#clopri-app-sdk-documentation)

Welcome to the **Clopri App SDK** guide. This SDK provides a set of powerful classes to handle networking, storage, caching, and core business entities (Products, Sales, People, Restocking, and Configuration) securely and efficiently.

---

**1. HTTP Networking**
======================

[](#1-http-networking)

### **Function:** `clopriFetch`

[](#function-cloprifetch)

A secure wrapper for making external HTTP requests. It includes built-in **Anti-SSRF** protection and handles header formatting automatically.

ParameterTypeDescription**`$url`**`string`The destination URL (http/s).**`$options`**`array`Configuration options (see table below).### **Options Configuration**

[](#options-configuration)

KeyDefaultDescription`method``'GET'`HTTP Verb (`GET`, `POST`, `PUT`, `DELETE`).`headers``[]`Array of headers.`body``null`Request payload (form-data array or JSON string).`timeout``5`Timeout in seconds (Max 15s).`verify_ssl``true`Enables/disables SSL verification.#### Example

[](#example)

```
// GET Request
$response = clopriFetch('[https://api.example.com/products](https://api.example.com/products)');
if ($response['ok']) {
    echo $response['body'];
}

// POST JSON Request
$response = clopriFetch('[https://api.example.com/orders](https://api.example.com/orders)', [
    'method' => 'POST',
    'headers' => ['Content-Type' => 'application/json'],
    'body' => json_encode(['product_id' => 123, 'qty' => 2])
]);
```

---

**2. Input Handling**
=====================

[](#2-input-handling)

### **Class:** `clopriRequest`

[](#class-cloprirequest)

Safely retrieves and sanitizes input from GET, POST, and JSON body.

MethodUsageDescription**`get`**`::get('key', default, 'type')`Reads sanitized `$_GET`.**`post`**`::post('key', default, 'type')`Reads sanitized `$_POST`.**`json`**`::json('key', default)`Reads JSON body.**Available Types:** `string`, `int`, `float`, `bool`, `email`, `url`, `array`.

#### Example

[](#example-1)

```
// URL: /app?id=50&active=true

// Get parameters safely
$id = clopriRequest::get('id', 0, 'int');
$isActive = clopriRequest::get('active', false, 'bool');

// Get JSON body data
$productName = clopriRequest::json('name', 'Untitled Product');
```

---

**3. Storage System (Sandbox)**
===============================

[](#3-storage-system-sandbox)

### **Class:** `clopriStorage`

[](#class-clopristorage)

Provides a secure storage isolated per `packageId`.

MethodUsageDescription**`save`**`::save('file.json', $data)`Saves content (auto JSON).**`read`**`::read('file.json')`Reads file or returns `null`.**`delete`**`::delete('file.json')`Deletes file.**`exists`**`::exists('file.json')`Checks file presence.**`listFiles`**`::listFiles()`Lists stored files.#### Example

[](#example-2)

```
// Save configuration
$config = ['theme' => 'dark', 'notifications' => true];
clopriStorage::save('settings.json', $config);

// Read configuration
$data = clopriStorage::read('settings.json');
```

---

**4. Caching System**
=====================

[](#4-caching-system)

### **Class:** `clopriCache`

[](#class-clopricache)

MethodUsageDescription**`set`**`::set('key', $val)`Stores cache value.**`get`**`::get('key')`Retrieves cache value or null.**`remove`**`::remove('key')`Deletes key.#### Example

[](#example-3)

```
// Check cache first
$stats = clopriCache::get('daily_stats');

if (!$stats) {
    // Calculate stats...
    $stats = ['visits' => 100, 'sales' => 5];
    // Save to cache
    clopriCache::set('daily_stats', $stats);
}
```

---

**5. Core Entities**
====================

[](#5-core-entities)

The SDK exposes several data classes to manage the ERP logic efficiently.

---

### **5.1 Class: `ProductData`**

[](#51-class-productdata)

Manages inventory items and services.

### **Public Properties**

[](#public-properties)

PropertyTypeDescription`$name``string`Product name.`$barcode``string`Unique code (SKU/UPC).`$price_in``float`Cost price.`$min_price``float`Minimum selling price.`$max_price``float`Selling price.`$quantityPerPackage``float`Quantity per package.`$category_id``int`Category ID.### **Public Methods**

[](#public-methods)

MethodDescription**`::getById($id)`**Retrieves a product by ID.**`::searchProduct($q, $limit)`**Searches by name/barcode.**`->add()`**Adds the product to the system.**`->update()`**Updates product information.#### Example

[](#example-4)

```
// Create a new product
$prod = new ProductData();
$prod->name = "Wireless Mouse";
$prod->barcode = "WM-001";
$prod->price_in = 10.00;
$prod->min_price = 20.00;
$prod->max_price = 25.00;
$prod->category_id = 1;
$prod->add();

// Search for a product
$results = ProductData::searchProduct("Mouse");
```

---

### **5.2 Class: `SellData`**

[](#52-class-selldata)

Manages the core lifecycle of sales transactions, including invoicing and receivables.

#### **Key Properties**

[](#key-properties)

PropertyTypeDescription**`$id`**`int`Unique identifier of the sale.**`$total`**`float`Final amount of the sale.**`$cash`**`float`Amount paid by the client.**`$person_id`**`int`ID of the client associated with the sale.**`$status`**`int`Status flag (`1` = Active, `0` = Inactive).**`$payment_method`**`string`E.g., `'Cash'`, `'Credit Card'`, `'Transfer'`.**`$ncf`**`string`Fiscal invoice number (Tax ID).**`$note`**`string`Optional internal notes.#### **Public Methods**

[](#public-methods-1)

MethodTypeDescription**`getSellIA`**`static`**AI Ready.** Returns a detailed dataset joining Sale + Items + Client.**`getAllSellByDate`**`static`Returns a list of `SellData` objects between two dates.**`getReportReceivable`**`static`**Financial.** Generates an Accounts Receivable report.**`getById`**`static`Retrieves a single sale object by its ID.**`add`**`instance`Saves the current sale object to the database.#### Example

[](#example-5)

```
// Create a new sale
$sale = new SellData();
$sale->person_id = 5;      // Client ID
$sale->total = 1500.00;    // Total Amount
$sale->cash = 1500.00;     // Amount Paid
$sale->payment_method = 'Credit Card';
$sale->note = "Sale created via API";
$sale->add();

// Check debts
$debts = SellData::getReportReceivable(null, null, null, null, 5);
```

---

### **5.3 Class: `PersonData`**

[](#53-class-persondata)

Handles Clients, Employees, and Providers.

### **Public Properties**

[](#public-properties-1)

PropertyTypeDescription`$name``string`First name.`$lastname``string`Last name.`$no``string`Identification number.`$email``string`Email address.`$phone``string`Phone number.`$client_type_id``int`Type: 1=COMPANY, 2=GOV, 3=PERSON, 4=UNIQUE, 5=EXEMPT.### **Public Methods**

[](#public-methods-2)

MethodDescription**`->add_client()`**Registers a new client.**`->add_employee()`**Registers a new employee.**`::getClientsActive()`**Returns active clients.**`::getById($id)`**Retrieves person details.#### Example

[](#example-6)

```
// Register a new client
$client = new PersonData();
$client->name = "John";
$client->lastname = "Doe";
$client->no = "001-0000000-0";
$client->client_type_id = 3;
$client->add_client();
```

---

### **5.4 Class: `CategoryData`**

[](#54-class-categorydata)

Manages product categories and classifications.

### **Public Properties**

[](#public-properties-2)

PropertyTypeDescription`$description``string`The name/label of the category.`$prefix``string`Short code for the category.`$type``int`Classification ID.### **Public Methods**

[](#public-methods-3)

MethodDescription**`->add()`**Creates a new category.**`->update()`**Updates existing category.**`->del($status)`**Soft deletes or restores a category.**`::getAllActive()`**Returns all active categories.#### Example

[](#example-7)

```
$cat = new CategoryData();
$cat->description = 'Electronics';
$cat->prefix = 'EL';
$cat->type = 1;
$cat->add();
```

---

### **5.5 Class: `ReData` (Restocking/Expenses)**

[](#55-class-redata-restockingexpenses)

Manages purchases, expenses, and inventory restocking.

### **Public Properties**

[](#public-properties-3)

PropertyTypeDescription`$person_id``int`Provider ID.`$total``float`Total amount of the invoice.`$itbis``float`Tax amount (ITBIS/VAT).`$ncf``string`Fiscal Invoice Number.`$invoiceNumber``string`Provider's internal invoice number.`$expirationDate``string`Invoice expiration date (YYYY-MM-DD).`$discount``float`Applied discount amount.`$delivery``float`Delivery costs.### **Public Methods**

[](#public-methods-4)

MethodDescription**`->add()`**Registers the purchase/expense.#### Example

[](#example-8)

```
$re = new ReData();
$re->person_id = 7; // Provider
$re->total = 230.00;
$re->itbis = 18.40;
$re->ncf = 'B0100000001';
$re->invoiceNumber = 'INV-999';
$re->add();
```

---

### **5.6 Class: `CotizationData` (Quotes)**

[](#56-class-cotizationdata-quotes)

Handles sales quotes/estimates for clients.

### **Public Properties**

[](#public-properties-4)

PropertyTypeDescription`$person_id``int`Client ID.`$subtotal``float`Amount before taxes.`$taxes``float`Tax amount.`$total``float`Final quote total.### **Public Methods**

[](#public-methods-5)

MethodDescription**`->add()`**Saves the quote to the system.#### Example

[](#example-9)

```
$quote = new CotizationData();
$quote->person_id = 10;
$quote->subtotal = 100.00;
$quote->taxes = 18.00;
$quote->total = 118.00;
$quote->add();
```

---

### **5.7 Class: `UserData`**

[](#57-class-userdata)

Manages system users and authentication credentials.

### **Public Properties**

[](#public-properties-5)

PropertyTypeDescription`$username``string`Unique login username.`$name``string`User's first name.`$lastname``string`User's last name.`$email``string`Contact email.`$password``string`Hashed password string.### **Public Methods**

[](#public-methods-6)

MethodDescription**`->add()`**Registers a new system user.#### Example

[](#example-10)

```
$user = new UserData();
$user->username = 'admin_user';
$user->name = 'Admin';
$user->lastname = 'User';
$user->email = 'admin@clopri.com';
$user->password = password_hash('securepass', PASSWORD_DEFAULT);
$user->add();
```

---

### **5.8 Class: `ConfigurationData`**

[](#58-class-configurationdata)

Handles global system settings.

### **Public Methods**

[](#public-methods-7)

MethodUsageDescription**`::updateValFromName`**`::updateValFromName('key', 'value')`Updates a specific configuration value.**`::getByPreffix`**`::getByPreffix('prefix')`Retrieves config values matching a prefix.#### Example

[](#example-11)

```
ConfigurationData::updateValFromName('company_name', 'My Business Inc.');
```

---

### **5.9 Class: `Utils`**

[](#59-class-utils)

Helper methods for common formatting tasks.

### **Public Methods**

[](#public-methods-8)

MethodUsageDescription**`moneyFormat`**`::moneyFormat('Symbol', $val)`Formats float to currency string.**`noPermissionPrint`**`::noPermissionPrint()`Returns standard error for permission denied.#### Example

[](#example-12)

```
echo Utils::moneyFormat('RD$', 1500.50);
// Output: RD$ 1,500.50
```

---

#### Clopri App SDK

[](#clopri-app-sdk)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance81

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

Every ~19 days

Total

4

Last Release

102d ago

Major Versions

1.1.0 → 3.4.62026-02-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/949b6c9d0f7f73c6d39cb4ec9cdb6f15cec7f46ad7bd1e534e167f3dbaf32a01?d=identicon)[clopri](/maintainers/clopri)

---

Top Contributors

[![yolfry](https://avatars.githubusercontent.com/u/16980004?v=4)](https://github.com/yolfry "yolfry (11 commits)")

### Embed Badge

![Health badge](/badges/clopri-appsdk/health.svg)

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

PHPackages © 2026

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