PHPackages                             sonypradana/php-library - 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. [Framework](/categories/framework)
4. /
5. sonypradana/php-library

ActiveLibrary[Framework](/categories/framework)

sonypradana/php-library
=======================

library to build php mvc

v0.41.2(3w ago)33.6k1[5 PRs](https://github.com/SonyPradana/php-library/pulls)2MITPHPPHP ^8.0CI passing

Since Sep 14Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/SonyPradana/php-library)[ Packagist](https://packagist.org/packages/sonypradana/php-library)[ RSS](/packages/sonypradana-php-library/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (19)Versions (146)Used By (2)

PHP MVC
=======

[](#php-mvc)

Php mvc with minum mvc framework. is simple and easy to use

> **Note:** This repository contains the core code of the php-mvc. If you want to build an application, visit the main [php-mvc](https://github.com/SonyPradana/php-mvc).

> **Note:** This repository high inspire with `laravel\framework` and `symfony\symfony`.

Feature
-------

[](#feature)

- MVC base
- Container (dependency injection)
- Route
- Model (database class relation)
- View and Controller
- [MyQuery](#Built-in-Query-Builder) (database query builder)
- [Collection](#Collection) (array collection)
- [Console](#Console) (assembling beutifull console app)
- Template (create class using class generator)
- Cron
- Now (time managing)
- Http request and responese
- [Str](#Str) (string manipulation)

**Built in Query Builder**
--------------------------

[](#built-in-query-builder)

of cource we are support CRUD data base, this a sample

### Select data

[](#select-data)

```
DB::table('table_name')
  ->select(['column_1'])
  ->equal('column_2', 'fast_mvc')
  ->order("column_1", MyQuery::ORDER_ASC)
  ->limit(1, 10)
  ->all()
;
```

the result will show data from query, its same with SQL query

```
SELECT `column_1` FROM `table_name` WHERE (`column_2` = 'fast_mvc') ORDER BY `table_name`.`column_1` ASC LIMIT 1, 10
```

[🔝 Back to contents](#Feature)

### Update data

[](#update-data)

```
DB::table('table_name')
  ->update()
  ->values([
    'column_1' => 'simple_mvc',
    'column_2' => 'fast_mvc',
    'column_3' => 123
  ])
  ->equal('column_4', 'fast_mvc')
  ->execute()
;
```

the result is boolen true if sql success excute quert, its same with SQL query

```
UPDATE `table_name` SET `column_1` = 'simple_mvc', `column_2` = 'fast_mvc', 'column_3' = 123  WHERE (`column_4` = 'speed')
```

[🔝 Back to contents](#Feature)

### Insert and Delete

[](#insert-and-delete)

```
// insert
DB::table('table_name')
  ->insert()
  ->values([
    'column_1'  => '',
    'column_2'  => 'simple_mvc',
    'column_3'  => 'fast_mvc'
    ])
  ->execute()
;

// delete
DB::table('table_name')
  ->delete()
  ->equal('column_3', 'slow_mvc')
  ->execute()
;
```

its supported cancel transation if you needed

```
use System\Support\Facades;

PDO::transaction(function() {
    DB::table('table_name')
        ->insert()
        ->value('age', 22)
        ->execute()
    ;

    // some condition
    if (false === $statment) {
        return false;
    }

    return true;
});
```

### Create Database Table

[](#create-database-table)

create database table

```
  Schema::table('users', function(Column $column) {
    $column('user')->varchar(50);
    $column('pwd')->varchar(500)->notNull();
    $column->primeryKeys('user');
  })
  ->excute();
```

[🔝 Back to contents](#Feature)

Collection
----------

[](#collection)

Array collection, handel functional array as chain method

### Create New Collection

[](#create-new-collection)

```
$coll = new Collection(['vb_net', 'c_sharp', 'java', 'python', 'php', 'javascript', 'html']);

$arr = $coll
  ->remove('html')
  ->sort()
  ->filter(fn ($item) => strlen($item) > 4)
  ->map(fn ($item) => ucfirst($item))
  ->each(function($item) {
    echo $item . PHP_EOL;
  })
  ->all()
;

// arr = ['c_sharp', 'javascript', 'python', 'vb_net']
```

[🔝 Back to contents](#Feature)

### Available Methods

[](#available-methods)

- `add()`
- `remove()`
- `set()`
- `clear()`
- `replace()`
- `each()`
- `map`
- `filter()`
- `sort()`
- `sortDesc()`
- `sortKey()`
- `sortKeyDesc()`
- `sortBy()`
- `sortByDecs()`
- `all()`

[🔝 Back to contents](#Feature)

Console
-------

[](#console)

Assembling beautifull console app make easy

- naming parameter
- coloring console (text and background)

### Build simple console app

[](#build-simple-console-app)

```
class GreatConsole extends Console
{
  public function main()
  {
    // getter to get param form cli argument
    $name = $this->name ?? 'animus';

    style("Great console Aapplication")
    	->textGreen()
        ->newLines()
        ->push("hay my name is ")
        ->push($name)
        ->textYellow()
        ->out()
    ;
  }
}
```

**Run your app**

- create bootstrapper

```
#!usr/bin/env php

// $argv come with default global php
return (new greatConsole($argv))->main();
```

- on your console

```
php cli greate --name php_mvc

# output:
# Great console application
# hay my name is php_mvc
```

[🔝 Back to contents](#Feature)

Str
---

[](#str)

Make string manipulation.

```
Str::chartAt('i love php', 3); // o
Str::concat(['i', 'love', 'php']); // i love php
Str::indexOf('i love php', 'p'); // 8
Str::lastIndexOf('i love php', 'p'); // 10
Str::match('i love php', '/love/'); // love
// ...
// and many more
```

- `chartAt`
- `concat`
- `indexOf`
- `lastIndexOf`
- `match`
- `slice`
- `split`
- `replace`
- `toUpperCase`
- `toLowerCase`
- `firstUpper`
- `firstUpperAll`
- `toSnackCase`
- `toKebabCase`
- `toPascalCase`
- `toCamelCase`
- `contains`
- `startsWith`
- `endsWith`
- `slug`
- `template`
- `length`
- `repeat`
- `isString`
- `isEmpty`
- `fill`
- `fillEnd`
- `limit`

### Costume macro

[](#costume-macro)

costume macro string;

```
Str::macro('prefix', fn($text, $prefix) => $prefix.$test);

echo Str::prefix('cool', 'its '); // its cool
```

### String class

[](#string-class)

use chain string class.

```
$string = new Text('I Love rust');

echo $string->replace('rust', 'php')->lower()->slug();
// i-love-php

echo $string->length(); // 10
echo $string->isEmpty(); // false
```

### String Regex

[](#string-regex)

```
Str::is('some@email.com', Regex::EMAIL); // true
```

avlilable regex

- `email`
- `user`
- `plain_text`
- `slug`
- `html_tag`
- `js_inline`
- `password_complex`
- `password_moderate`
- `date_yyyymmdd`
- `date_ddmmyyyy`
- `date_ddmmmyyyy`
- `ip4`
- `ip6`
- `ip4_6`
- `url`

[🔝 Back to contents](#Feature)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance92

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 93.8% 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 ~17 days

Recently: every ~47 days

Total

100

Last Release

22d ago

PHP version history (2 changes)v0.7.0PHP ^7.4 || ^8.0

v0.33.0PHP ^8.0

### Community

Maintainers

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

---

Top Contributors

[![SonyPradana](https://avatars.githubusercontent.com/u/7188706?v=4)](https://github.com/SonyPradana "SonyPradana (603 commits)")[![anggerpradana](https://avatars.githubusercontent.com/u/75710827?v=4)](https://github.com/anggerpradana "anggerpradana (40 commits)")

---

Tags

libraryphpframeworkPHP Libraryphp-mvc

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sonypradana-php-library/health.svg)

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

###  Alternatives

[skipify/vitex

A Tiny Framework.轻量级的php resetful框架.

122.0k](/packages/skipify-vitex)

PHPackages © 2026

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