sonypradana / php-library
library to build php mvc
Installs: 2 889
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 5
pkg:composer/sonypradana/php-library
Requires
- php: ^8.0
- ext-mbstring: *
- php-di/php-di: ^7.1
- sonypradana/validator: ^0.8
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.88
- mockery/mockery: ^1.6
- phpstan/phpstan: ^1.12
- phpunit/phpunit: ^9.6
- rector/rector: ^1.2
Replaces
- sonypradana/cache: v0.40.3
- sonypradana/collection: v0.40.3
- sonypradana/console: v0.40.3
- sonypradana/container: v0.40.3
- sonypradana/cron: v0.40.3
- sonypradana/database: v0.40.3
- sonypradana/file: v0.40.3
- sonypradana/http: v0.40.3
- sonypradana/ratelimiter: v0.40.3
- sonypradana/router: v0.40.3
- sonypradana/security: v0.40.3
- sonypradana/support: v0.40.3
- sonypradana/template: v0.40.3
- sonypradana/text: v0.40.3
- sonypradana/time: v0.40.3
- sonypradana/view: v0.40.3
- dev-master / 0.x-dev
- v0.40.3
- v0.40.2
- v0.40.1
- v0.40.0
- v0.39.2
- v0.39.1
- v0.39.0
- v0.38.3
- v0.38.2
- v0.38.1
- v0.38.0
- v0.37.1
- v0.37.0
- v0.36.6
- v0.36.5
- v0.36.4
- v0.36.3
- v0.36.2
- v0.36.1
- v0.36.0
- v0.35.6
- v0.35.5
- v0.35.4
- v0.35.3
- v0.35.2
- v0.35.1
- v0.35.0
- v0.34.1
- v0.34.0
- v0.33.0
- v0.32.x-dev
- v0.32.4
- v0.32.3
- v0.32.2
- v0.32.1
- v0.32.0
- v0.31.1
- v0.31.0
- v0.30.0
- v0.29.1
- v0.29.0
- v0.28.0
- v0.27.4
- v0.27.3
- v0.27.2
- v0.27.1
- v0.27.0
- v0.26.2
- v0.26.1
- v0.26.0
- v0.25.1
- v0.25.0
- v0.24.0
- v0.23.0
- v0.22.1
- v0.22.0
- v0.21.1
- v0.21.0
- v0.20
- v0.19.1
- v0.19.0
- v0.18.0
- v0.17.0
- v0.16.0
- v0.15.0
- v0.14.0
- v0.13.0
- v0.12.4
- v0.12.3
- v0.12.2
- v0.12.1
- v0.12.0
- v0.11.1
- v0.11.0
- v0.10.5
- v0.10.4
- v0.10.3
- v0.10.2
- v0.10.1
- v0.10.0
- v0.9.1
- v0.9.0
- v0.8.0
- v0.7.1
- v0.7.0
- v0.6.2
- v0.6.1
- v0.6.0
- v0.5.0
- v0.4.0
- v0.3.0
- v0.2.1
- v0.2.0
- v0.1.3
- v0.1.2
- v0.1.1
- dev-revent/pdo-facade-database-manager
- dev-fix/database-pdo-interface
- dev-doc
- dev-feat/vite-facade
- dev-revert-backtick-factory
- dev-revert-backtick
- dev-feat/application-defer
- dev-refactor/now-extend-datetime
- dev-fix/alter-builder-delimater
- dev-fix/migration-batch
- dev-remove/remove-monorepo-builder
- dev-remove/remove-route-controller
- dev-dev
- dev-refactor/package-manifest-config
- dev-feat/package-manifest-checker
- dev-bump-phpunit-ver-10
- dev-feat-console-karnel-report-handler
- dev-templator-with-manifestor
- dev-pipeline
- dev-router-invoke
- dev-route-redirect
- dev-console-style-rule
- dev-cron-logger
- dev-controller-type
- dev-rector
- dev-console-box
- dev-optional-autoload
- dev-collection-type-single-template
- dev-app-config
- dev-db-excute
This package is auto-updated.
Last update: 2025-10-18 06:59:45 UTC
README
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.
Note: This repository high inspire with
laravel\frameworkandsymfony\symfony.
Feature
- MVC base
- Container (dependency injection)
- Route
- Model (database class relation)
- View and Controller
- MyQuery (database query builder)
- Collection (array collection)
- Console (assembling beutifull console app)
- Template (create class using class generator)
- Cron
- Now (time managing)
- Http request and responese
- Str (string manipulation)
Built in Query Builder
of cource we are support CRUD data base, this a sample
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
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')
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
Schema::table('users', function(Column $column) { $column('user')->varchar(50); $column('pwd')->varchar(500)->notNull(); $column->primeryKeys('user'); }) ->excute();
Collection
Array collection, handel functional array as chain method
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']
Available Methods
add()remove()set()clear()replace()each()mapfilter()sort()sortDesc()sortKey()sortKeyDesc()sortBy()sortByDecs()all()
Console
Assembling beautifull console app make easy
- naming parameter
- coloring console (text and background)
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
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
chartAtconcatindexOflastIndexOfmatchslicesplitreplacetoUpperCasetoLowerCasefirstUpperfirstUpperAlltoSnackCasetoKebabCasetoPascalCasetoCamelCasecontainsstartsWithendsWithslugtemplatelengthrepeatisStringisEmptyfillfillEndlimit
Costume macro
costume macro string;
Str::macro('prefix', fn($text, $prefix) => $prefix.$test); echo Str::prefix('cool', 'its '); // its cool
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
Str::is('some@email.com', Regex::EMAIL); // true
avlilable regex
emailuserplain_textslughtml_tagjs_inlinepassword_complexpassword_moderatedate_yyyymmdddate_ddmmyyyydate_ddmmmyyyyip4ip6ip4_6url