PHPackages                             hoanglong2905/php-utils - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hoanglong2905/php-utils

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hoanglong2905/php-utils
=======================

A simple PHP package for php utilities.

v1.0.3(9mo ago)034MITPHP

Since Sep 10Pushed 9mo agoCompare

[ Source](https://github.com/hoanglong2905/php-utils)[ Packagist](https://packagist.org/packages/hoanglong2905/php-utils)[ RSS](/packages/hoanglong2905-php-utils/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (5)Used By (0)

Array Utils
===========

[](#array-utils)

Một package giúp làm việc với PHP.

Cài đặt
-------

[](#cài-đặt)

### Cài đặt bằng Composer (Khuyến nghị)

[](#cài-đặt-bằng-composer-khuyến-nghị)

```
composer require hoanglong2905/php-utils
```

### Hoặc sử dụng thủ công (require từng file)

[](#hoặc-sử-dụng-thủ-công-require-từng-file)

Chỉ cần copy các file cần dùng trong thư mục `src` vào project của bạn. Ví dụ:

```
require_once '/path/to/ImageHelper.php';
require_once '/path/to/ArrayHelper.php';
require_once '/path/to/ApiHelper.php';

use PHPUtils\ImageHelper;
// ...
```

Sử dụng
-------

[](#sử-dụng)

### ImageHelper

[](#imagehelper)

> **Lưu ý:** Nếu không truyền `savePath` hoặc truyền giá trị không hợp lệ, các hàm sẽ tự động lưu ảnh vào thư mục `public/created_image` ở thư mục gốc project và trả về đường dẫn file vừa lưu.

```
require 'vendor/autoload.php';

use PHPUtils\ImageHelper;

// Tạo ảnh và tự động lưu vào public/created_image
$autoPath = ImageHelper::createImage(200, 100, null, 'png', [0,128,255]);
echo $autoPath; // Đường dẫn file ảnh vừa tạo

// Tạo ảnh và lưu trực tiếp ra file chỉ định
$savePath = 'my_image.png';
ImageHelper::createImage(300, 200, $savePath, 'png', [255,255,0]);

// Lấy ảnh miễn phí và tự động lưu vào public/created_image
$freeImgPath = ImageHelper::getRandomFreeImage(400, 300);
echo $freeImgPath; // Đường dẫn file ảnh miễn phí

// Lấy ảnh miễn phí và lưu ra file chỉ định
ImageHelper::getRandomFreeImage(400, 300, 'free.jpg');
```

### ArrayHelper

[](#arrayhelper)

```
require 'vendor/autoload.php';

use PHPUtils\ArrayHelper;

$array = [1, 2, 3];

// Lấy phần tử đầu tiên
$first = ArrayHelper::first($array);

// Lấy phần tử cuối cùng
$last = ArrayHelper::last($array);

// Kiểm tra mảng liên kết
$isAssoc = ArrayHelper::isAssoc(['a' => 1, 'b' => 2]);

// Xem nhanh giá trị mảng (dừng chương trình)
ArrayHelper::view($array);
```

### ApiHelper

[](#apihelper)

```
require 'vendor/autoload.php';

use PHPUtils\ApiHelper;

// Gọi GET
$getResult = ApiHelper::get('https://jsonplaceholder.typicode.com/posts', ['userId' => 1]);
print_r(json_decode($getResult['response'], true));

// Gọi POST
$postResult = ApiHelper::post('https://jsonplaceholder.typicode.com/posts', [
    'title' => 'foo',
    'body' => 'bar',
    'userId' => 1
]);
print_r(json_decode($postResult['response'], true));

// Gọi PUT
$putResult = ApiHelper::put('https://jsonplaceholder.typicode.com/posts/1', [
    'id' => 1,
    'title' => 'updated',
    'body' => 'baz',
    'userId' => 1
]);
print_r(json_decode($putResult['response'], true));

// Gọi DELETE
$deleteResult = ApiHelper::delete('https://jsonplaceholder.typicode.com/posts/1');
print_r(json_decode($deleteResult['response'], true));
```

Tác giả
-------

[](#tác-giả)

- Hoang Long

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance55

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

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 ~0 days

Total

4

Last Release

297d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/101849685?v=4)[hoanglong2905](/maintainers/hoanglong2905)[@hoanglong2905](https://github.com/hoanglong2905)

---

Top Contributors

[![hoanglong2905](https://avatars.githubusercontent.com/u/101849685?v=4)](https://github.com/hoanglong2905 "hoanglong2905 (6 commits)")

### Embed Badge

![Health badge](/badges/hoanglong2905-php-utils/health.svg)

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

PHPackages © 2026

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