PHPackages                             arefshojaei/kitdash - 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. arefshojaei/kitdash

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

arefshojaei/kitdash
===================

PHP utility library

1.4.4(2w ago)018MITPHPPHP ^8.0

Since Jun 21Pushed 2w ago1 watchersCompare

[ Source](https://github.com/ArefShojaei/KitDash)[ Packagist](https://packagist.org/packages/arefshojaei/kitdash)[ RSS](/packages/arefshojaei-kitdash/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

🎯 KitDash
=========

[](#-kitdash)

[![Latest Version](https://camo.githubusercontent.com/b0d73d86648ec63265340b06c0f6e4272d6d4326fdaa90231fe398aac0bea197/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6172656673686f6a6165692f6b6974646173682e737667)](https://packagist.org/packages/arefshojaei/kitdash)[![PHP Version](https://camo.githubusercontent.com/6da9704adc310b64eea60cc463a5e5c8dd738da86ba6c3e2af0cfd4600621755/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e302d626c75652e737667)](https://php.net)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

**KitDash** is a lightweight and flexible PHP utility library designed to speed up development by providing reusable, well-tested helper functions and components. Inspired by [Laravel](https://laravel.com) and [Lodash](https://lodash.com).

---

✨ Features
----------

[](#-features)

- 🚀 **Comprehensive Utilities** - Array, String and File utilities
- 🏗️ **Data Structures** - Stack, HashTable, Tree, Graph
- 📦 **Clean Architecture** - Interfaces and Traits for modular code
- 🧪 **Well Tested** - All functions covered with PHPUnit
- ⚡ **High Performance** - Zero external dependencies
- 🔒 **PHP 8.0+** - Modern PHP features
- 📚 **Easy to Use** - Simple and consistent API

---

📥 Installation
--------------

[](#-installation)

### With Composer (Recommended)

[](#with-composer-recommended)

```
composer require arefshojaei/kitdash
```

### Manual Installation

[](#manual-installation)

```
git clone https://github.com/ArefShojaei/KitDash.git
cd KitDash
composer install
```

---

🚀 Quick Start
-------------

[](#-quick-start)

### Array Utilities

[](#array-utilities)

```
use Kit\Utils\Arr;

// Add an element
$array = Arr::add(['a' => 1], 'b', 2);
// ['a' => 1, 'b' => 2]

// Get an element
$value = Arr::get(['a' => 1, 'b' => 2], 'a'); // 1
$default = Arr::get(['a' => 1], 'c', 'default'); // 'default'

// Take first N elements
$first = Arr::take([1, 2, 3, 4, 5], 3); // [1, 2, 3]

// Get element by index
$nth = Arr::nth([10, 20, 30], 1); // 20

// Drop elements
$dropped = Arr::drop([1, 2, 3], 1); // [2, 3]

// Remove falsey elements
$compact = Arr::compact([0, '', false, 'hello', null]); // ['hello']

// Remove specific element
$except = Arr::except(['a' => 1, 'b' => 2], 'a'); // ['b' => 2]

// First and last element
$first = Arr::first([1, 2, 3]); // 1
$last = Arr::last([1, 2, 3]); // 3

// Filter by keys
$only = Arr::only(['a' => 1, 'b' => 2, 'c' => 3], ['a', 'c']); // ['a' => 1, 'c' => 3]

// Fill array
$filled = Arr::fill([1, 2, 3], 'x'); // ['x', 'x', 'x']

// Sort array
$sorted = Arr::sort([3, 1, 4, 1, 5]); // [1, 1, 3, 4, 5]

// Remove duplicates
$unique = Arr::unique([1, 2, 2, 3, 3, 3]); // [1, 2, 3]

// Concatenate arrays
$concatenated = Arr::concat([1, 2], [3, 4]); // [1, 2, 3, 4]

// Get random element
$random = Arr::random([1, 2, 3, 4, 5]); // random element
```

### String Utilities

[](#string-utilities)

```
use Kit\Utils\Str;

// Convert to uppercase
$upper = Str::upper('hello'); // 'HELLO'

// Convert to lowercase
$lower = Str::lower('HELLO'); // 'hello'

// Convert to title case
$title = Str::title('hello world'); // 'Hello World'

// Capitalize first character
$capitalize = Str::capitalize('hello'); // 'Hello'

// Check if string contains substring
$contains = Str::contains('hello world', 'world'); // true

// Check if string starts with substring
$starts = Str::startsWith('hello world', 'hello'); // true

// Check if string ends with substring
$ends = Str::endsWith('hello world', 'world'); // true

// Replace substring
$replace = Str::replace('hello world', 'world', 'php'); // 'hello php'

// Split string
$split = Str::split('a,b,c', ','); // ['a', 'b', 'c']

// Trim whitespace
$trim = Str::trim('  hello  '); // 'hello'

// Repeat string
$repeat = Str::repeat('ha', 3); // 'hahaha'

// Limit string length
$limit = Str::limit('hello world', 5); // 'hello...'

// Convert to slug
$slug = Str::slug('My Awesome Post'); // 'my-awesome-post'

// Count characters
$count = Str::count('hello'); // 5

// Base64 encoding
$encoded = Str::base64Encode('hello'); // 'aGVsbG8='
$decoded = Str::base64Decode('aGVsbG8='); // 'hello'

// HTML escape
$escaped = Str::htmlEscape(''); // '&lt;script&gt;'

// HTML unescape
$unescaped = Str::htmlUnescape('&lt;script&gt;'); // ''
```

### File Utilities

[](#file-utilities)

```
use Kit\Utils\Fs\File;

// Save file
$saved = File::save('path/to/file.txt', 'File content');

// Read file
$content = File::get('path/to/file.txt');

// Check if file exists
$exists = File::has('path/to/file.txt'); // true/false
```

### Data Structures

[](#data-structures)

#### Stack (LIFO - Last In First Out)

[](#stack-lifo---last-in-first-out)

```
use Kit\Container\Stack;

$stack = new Stack();

// Push element
$stack->push('first');
$stack->push('second');
$stack->push('third');

// Pop element
$item = $stack->pop(); // 'third'

// Convert to array
$array = $stack->toArray(); // ['first', 'second']
```

#### HashTable

[](#hashtable)

```
use Kit\Container\HashTable;

$table = new HashTable();

// Set value
$table->set('user_1', 'John Doe');
$table->set('user_2', 'Jane Doe');

// Get value
$value = $table->get('user_1'); // 'John Doe'

// Check if key exists
$exists = $table->has('user_1'); // true

// Convert to array
$all = $table->toArray();
```

#### Tree

[](#tree)

```
use Kit\Entity\Tree;

$root = new Tree('Root');
$child = new Tree('Child');

// Access value
echo $root->value; // 'Root'
```

#### Graph

[](#graph)

```
use Kit\Contracts\Interfaces\Graph;

$graph = new Graph();

// Add nodes
$node1 = $graph->addNode('Node1');
$node2 = $graph->addNode('Node2');

// Add edge
$graph->addEdge($node1, $node2);

// Get node
$node = $graph->getNode('Node1');
```

---

📚 Complete API Reference
------------------------

[](#-complete-api-reference)

### Kit\\Utils\\Arr - Array Methods

[](#kitutilsarr---array-methods)

MethodDescriptionExample`add(array, key, value)`Add element to array`Arr::add($arr, 'id', 1)``get(array, key, default)`Get element from array`Arr::get($arr, 'id', null)``take(array, length)`Take first N elements`Arr::take($arr, 3)``nth(array, index)`Get element by index`Arr::nth($arr, 0)``drop(array, index)`Drop element at index`Arr::drop($arr, 1)``compact(array)`Remove falsey elements`Arr::compact($arr)``except(array, key)`Remove specific element`Arr::except($arr, 'id')``first(array)`Get first element`Arr::first($arr)``last(array)`Get last element`Arr::last($arr)``only(array, keys)`Filter by keys`Arr::only($arr, ['id', 'name'])``fill(array, value)`Fill array with value`Arr::fill($arr, 'x')``sort(array)`Sort array ascending`Arr::sort($arr)``unique(array)`Remove duplicates`Arr::unique($arr)``concat(...arrays)`Concatenate arrays`Arr::concat($arr1, $arr2)``random(array)`Get random element`Arr::random($arr)``chunk(array, size)`Split into chunks`Arr::chunk($arr, 2)``column(array, key)`Extract column`Arr::column($arr, 'id')``reverse(array)`Reverse array`Arr::reverse($arr)``merge(...arrays)`Merge arrays`Arr::merge($arr1, $arr2)``values(array)`Get array values`Arr::values($arr)`### Kit\\Utils\\Str - String Methods

[](#kitutilsstr---string-methods)

MethodDescriptionExample`upper(string)`Convert to uppercase`Str::upper('hello')``lower(string)`Convert to lowercase`Str::lower('HELLO')``title(string)`Convert to title case`Str::title('hello world')``capitalize(string)`Capitalize first letter`Str::capitalize('hello')``contains(string, search)`Check if contains substring`Str::contains('hello', 'ell')``startsWith(string, prefix)`Check if starts with`Str::startsWith('hello', 'he')``endsWith(string, suffix)`Check if ends with`Str::endsWith('hello', 'lo')``replace(string, search, replace)`Replace substring`Str::replace('hello', 'h', 'H')``split(string, separator)`Split string`Str::split('a,b,c', ',')``trim(string)`Remove whitespace`Str::trim('  hello  ')``repeat(string, times)`Repeat string`Str::repeat('ha', 3)``limit(string, length, end)`Limit string length`Str::limit('hello world', 5)``slug(string)`Convert to slug`Str::slug('Hello World')``count(string)`Count characters`Str::count('hello')``base64Encode(string)`Encode to base64`Str::base64Encode('hello')``base64Decode(string)`Decode from base64`Str::base64Decode('aGVs...')``htmlEscape(string)`Escape HTML`Str::htmlEscape('')``htmlUnescape(string)`Unescape HTML`Str::htmlUnescape('&lt;')``reverse(string)`Reverse string`Str::reverse('hello')``pad(string, length, pad)`Pad string`Str::pad('hello', 10, '*')``random(length)`Generate random string`Str::random(10)`### Kit\\Utils\\Fs\\File - File Methods

[](#kitutilsfsfile---file-methods)

MethodDescriptionExample`save(path, data)`Save file`File::save('file.txt', 'content')``get(path)`Read file`File::get('file.txt')``has(path)`Check if file exists`File::has('file.txt')`### Kit\\Container\\Stack - Stack Methods

[](#kitcontainerstack---stack-methods)

MethodDescription`push(value)`Push element to stack`pop()`Pop element from stack`toArray()`Convert to array### Kit\\Container\\HashTable - HashTable Methods

[](#kitcontainerhashtable---hashtable-methods)

MethodDescription`set(key, value)`Set value`get(key)`Get value`has(key)`Check if key exists`toArray()`Convert to array---

💡 Practical Examples
--------------------

[](#-practical-examples)

### Real-world Data Processing

[](#real-world-data-processing)

```
use Kit\Utils\Arr;
use Kit\Utils\Str;

// Sample user data
$users = [
    ['id' => 1, 'name' => 'John', 'email' => 'john@example.com', 'status' => 'active'],
    ['id' => 2, 'name' => 'Jane', 'email' => 'jane@example.com', 'status' => 'inactive'],
    ['id' => 3, 'name' => 'Bob', 'email' => 'bob@example.com', 'status' => 'active'],
];

// Get only active users
$active = array_filter($users, fn($user) => $user['status'] === 'active');

// Extract emails
$emails = array_map(fn($user) => $user['email'], $users);

// Extract specific fields
$ids = Arr::column($users, 'id'); // [1, 2, 3]
```

### Input Data Cleaning

[](#input-data-cleaning)

```
use Kit\Utils\Str;
use Kit\Utils\Arr;

$input = [
    'name' => '  John Doe  ',
    'email' => 'JOHN@EXAMPLE.COM',
    'description' => '',
    'website' => null,
];

// Clean input
$input['name'] = Str::trim($input['name']);
$input['email'] = Str::lower($input['email']);

// Remove empty values
$clean = Arr::compact($input);

// Result: ['name' => 'John Doe', 'email' => 'john@example.com']
```

### Working with URLs and Slugs

[](#working-with-urls-and-slugs)

```
use Kit\Utils\Str;

$title = 'How to Build a PHP Application';

// Create URL-friendly slug
$slug = Str::slug($title); // 'how-to-build-a-php-application'

// Create filename
$filename = $slug . '.md'; // 'how-to-build-a-php-application.md'

// Check URL patterns
$isValid = Str::startsWith('https://example.com/api', 'https://');
```

### Working with Configuration

[](#working-with-configuration)

```
use Kit\Utils\Arr;

$config = [
    'app' => ['name' => 'MyApp', 'version' => '1.0'],
    'db' => ['host' => 'localhost', 'port' => 3306],
    'cache' => ['driver' => 'redis'],
];

// Get specific values
$appName = Arr::get($config, 'app'); // Using array keys
$dbHost = Arr::get($config, 'db');

// Add new config
$newConfig = Arr::add($config, 'queue', ['driver' => 'redis']);

// Get only app config
$appConfig = Arr::only($config['app'], ['name', 'version']);
```

### File Operations

[](#file-operations)

```
use Kit\Utils\Fs\File;

// Save configuration
$config = ['app' => 'MyApp', 'debug' => true];
File::save('config.json', json_encode($config));

// Read configuration
if (File::has('config.json')) {
    $content = File::get('config.json');
    $config = json_decode($content, true);
}

// Create backup
$original = File::get('data.txt');
File::save('data.backup.txt', $original);
```

### Using Data Structures

[](#using-data-structures)

```
use Kit\Container\Stack;
use Kit\Container\HashTable;

// Undo/Redo functionality with Stack
$stack = new Stack();
$stack->push('action1');
$stack->push('action2');
$stack->push('action3');

$lastAction = $stack->pop(); // 'action3'

// Cache with HashTable
$cache = new HashTable();
$cache->set('user:1', ['name' => 'John', 'email' => 'john@example.com']);
$cache->set('user:2', ['name' => 'Jane', 'email' => 'jane@example.com']);

$user = $cache->get('user:1');
$hasUser = $cache->has('user:1'); // true
```

---

🧪 Testing
---------

[](#-testing)

### Install Development Dependencies

[](#install-development-dependencies)

```
composer install
```

### Run All Tests

[](#run-all-tests)

```
vendor/bin/phpunit
```

### Run Specific Test

[](#run-specific-test)

```
vendor/bin/phpunit --filter "testArrayAdd"
```

### Run Tests in Specific File

[](#run-tests-in-specific-file)

```
vendor/bin/phpunit tests/Unit/ArrayTest.php
```

### Generate Code Coverage Report

[](#generate-code-coverage-report)

```
vendor/bin/phpunit --coverage-html coverage
```

### Run Tests with Verbose Output

[](#run-tests-with-verbose-output)

```
vendor/bin/phpunit -v
```

---

🤝 Contributing
--------------

[](#-contributing)

We welcome contributions! Please follow these steps:

1. **Fork** the repository
2. Create a new **branch** (`git checkout -b feature/amazing-feature`)
3. **Commit** your changes (`git commit -m 'Add amazing feature'`)
4. **Push** to the branch (`git push origin feature/amazing-feature`)
5. Open a **Pull Request**

### Contributing Guidelines

[](#contributing-guidelines)

- All new functions must be tested
- Follow PSR-12 coding standards
- Commit messages should be clear and descriptive
- Update documentation if API changes
- Add examples for new utilities

---

🚀 Performance
-------------

[](#-performance)

KitDash is designed for performance:

- **Zero external dependencies** - Fast installation and updates
- **Static methods** - No object instantiation overhead
- **Optimized algorithms** - Efficient implementations
- **Minimal memory footprint** - Small library size

### Benchmark Results

[](#benchmark-results)

```
Array Operations: ~0.001ms per operation
String Operations: ~0.0001ms per operation
File Operations: I/O limited

```

---

🔒 Security
----------

[](#-security)

- **No external dependencies** - No supply chain vulnerabilities
- **Regular security audits** - Code reviewed for vulnerabilities
- **Input validation** - Safe string handling
- **Best practices** - Follow OWASP guidelines

---

👨‍💻 Author
----------

[](#‍-author)

**Aref Shojaei**

- 📧 Email:
- 🐙 GitHub: [@ArefShojaei](https://github.com/ArefShojaei)
- 📦 Packagist: [arefshojaei/kitdash](https://packagist.org/packages/arefshojaei/kitdash)

---

🙏 Acknowledgments
-----------------

[](#-acknowledgments)

- Inspired by [Laravel Helpers](https://laravel.com/docs/helpers)
- Inspired by [Lodash](https://lodash.com)
- Thanks to all [contributors](https://github.com/ArefShojaei/KitDash/graphs/contributors)

---

📞 Support &amp; Community
-------------------------

[](#-support--community)

### Need Help?

[](#need-help)

- 📖 **Documentation** - See examples above
- 🐛 **Found a bug?** - Open an [Issue](https://github.com/ArefShojaei/KitDash/issues)
- 💬 **Have a question?** - Start a [Discussion](https://github.com/ArefShojaei/KitDash/discussions)
- 📧 **Email** -

---

🌟 Show Your Support
-------------------

[](#-show-your-support)

If this project helped you, please give it a **⭐ Star on GitHub!**

It helps us reach more developers and keep improving the library.

**[⭐ Star us on GitHub](https://github.com/ArefShojaei/KitDash)**

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance91

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

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

Total

3

Last Release

17d ago

### Community

Maintainers

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

---

Top Contributors

[![ArefShojaei](https://avatars.githubusercontent.com/u/134844185?v=4)](https://github.com/ArefShojaei "ArefShojaei (9 commits)")

---

Tags

class-utilitylaravelloadashpackagephpphp-libraryphp8utilutilitiesutility-libraryutilslaravelhelperlibraryutilkitloadash

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/arefshojaei-kitdash/health.svg)

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k132.8M891](/packages/barryvdh-laravel-ide-helper)[kevinlebrun/password.php

Helpers for password generation and validation

21146.5k1](/packages/kevinlebrun-passwordphp)

PHPackages © 2026

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