jahurul1/ji-framework
Composer 安装命令:
composer require jahurul1/ji-framework
包简介
A lightweight and efficient PHP framework designed to simplify web application development. Features timezone-aware DateTimeHelper, database query builder, security tools, and comprehensive utility classes.
README 文档
README
JiFramework is a lightweight, plug-and-play PHP framework built for developers who want to move fast without sacrificing structure.
Whether you're prototyping a side project or shipping a production application, JiFramework gives you a fully wired environment — database, authentication, caching, logging, validation, encryption, and more — all ready in two lines of code. No CLI tools to learn, no template engine to configure, no boilerplate to write. Just install, instantiate, and build.
Built on plain PHP with zero mandatory configuration, JiFramework stays out of your way while giving you the power to handle anything from simple REST APIs to full multi-language web applications.
Two lines to start:
require __DIR__ . '/vendor/autoload.php'; $app = new JiFramework\Core\App\App();
That's it — database, auth, cache, logging, validation, and more are all ready.
Why JiFramework?
- Zero boilerplate — no commands to run, no code generation steps
- No template engine — use plain PHP files as views
- No CLI tools — everything works out of the box
- Lazy loading — components are created only when accessed; unused services cost nothing
- Optional router — use URL routing or skip it entirely (plug-and-play mode)
- Production ready — structured logging, CSRF protection, IP/country blocking, rate limiting, encryption
Requirements
- PHP 7.4 or higher
- Composer
- MySQL / MariaDB (optional — only needed for database features)
Installation
composer require jahurul1/ji-framework
Quick Start
<?php require __DIR__ . '/vendor/autoload.php'; use JiFramework\Core\App\App; $app = new App(); // Query the database $users = $app->db->table('users')->where('active', '=', 1)->get(); // Log something $app->logger->info('Page loaded', ['user_count' => count($users)]); // Validate input $v = $app->validator->make($_POST, [ 'email' => 'required|email', 'name' => 'required|min:2|max:100', ]); if ($v->fails()) { $errors = $v->errors(); }
Configuration
Copy the example config to your project root and fill in your values:
cp vendor/jahurul1/jiframework/jiconfig.example.php jiconfig.php
JiFramework auto-detects jiconfig.php — no manual path setup needed. You only need to define the keys you want to change; everything else falls back to sensible defaults.
// jiconfig.php return [ 'app_mode' => 'production', 'timezone' => 'Asia/Dhaka', 'database' => [ 'host' => 'localhost', 'database' => 'my_db', 'username' => 'root', 'password' => 'secret', ], 'log_enabled' => true, 'rate_limit_enabled' => true, 'router_enabled' => true, ];
Router Mode
Enable routing in jiconfig.php (router_enabled => true) and define routes in index.php:
$app->router->get('/', 'pages/home.php'); $app->router->get('/users/{id}', 'pages/user.php'); // $id available in file $app->router->get('/ping', function () { header('Content-Type: application/json'); echo json_encode(['status' => 'ok']); }); $app->router->post('/login', 'pages/auth/login.php'); $app->router->group(['prefix' => '/admin'], function ($r) { $r->get('/dashboard', 'pages/admin/dashboard.php'); $r->get('/users', 'pages/admin/users.php'); }); $app->router->dispatch();
Components
| Component | Access | Description |
|---|---|---|
| QueryBuilder | $app->db |
Fluent SQL builder — SELECT, INSERT, UPDATE, DELETE, JOINs, aggregates, transactions |
| Model | extend Model |
Active Record-style base class for database tables |
| Auth | $app->auth |
User & admin authentication, remember-me tokens |
| Session | $app->sessionManager |
Session management, flash messages, CSRF tokens |
| Validator | $app->validator |
Fluent input validation with 20+ built-in rules |
| Router | $app->router |
Optional URL router — file or closure handlers, route groups, params |
| Cache | $app->cache |
File or SQLite cache driver with TTL, increment/decrement |
| Logger | $app->logger |
PSR-3 structured logger with log rotation and level filtering |
| Encryption | $app->encryption |
AES-256-GCM encryption, password hashing, secure random tokens |
| RateLimiter | $app->rateLimiter |
Request rate limiting with IP ban support |
| AccessControl | $app->accessControl |
IP and country blocking |
| HttpClient | $app->http |
HTTP client for external API requests |
| FileManager | $app->fileManager |
File read/write, upload handling, directory utilities |
| Str | $app->str |
String utilities — slugify, mask, case conversion, truncate, and more |
| Paginator | $app->paginator |
Pagination with QueryBuilder integration |
| DateTimeHelper | $app->dateTime |
Date/time arithmetic, formatting, timezone conversion |
| ExecutionTimer | $app->executionTimer |
Measure code execution time |
| Request | $app->request |
Client IP detection, request headers, bearer token, AJAX/HTTPS/CLI detection |
| Url | $app->url |
URL parsing, building, query param manipulation |
| Localization | $app->language |
Multi-language support via JSON files |
| ErrorHandler | automatic | Structured error handling, custom error pages, named HTTP exceptions |
| Exceptions | $app->abort() |
HttpException, NotFoundException, ForbiddenException, ValidationException, and more |
Code Examples
Database — QueryBuilder
// Select with conditions $users = $app->db->table('users') ->where('active', '=', 1) ->where('age', '>', 18) ->orderBy('name', 'ASC') ->limit(10) ->get(); // Insert and get ID $id = $app->db->table('users')->insertGetId([ 'name' => 'Alice', 'email' => 'alice@example.com', ]); // Update $app->db->table('users')->where('id', '=', $id)->update(['active' => 0]); // Paginate $result = $app->db->table('posts')->orderBy('id', 'DESC')->paginate(15, 1); // $result->data, $result->totalItems, $result->totalPages
Model
class Post extends JiFramework\Core\Database\Model { protected static string $table = 'posts'; protected static string $primaryKey = 'id'; } Post::all(); Post::find(1); Post::where('published', '=', 1)->orderBy('created_at', 'DESC')->get(); Post::create(['title' => 'Hello', 'body' => '...']); Post::update(['title' => 'Updated'], 1); Post::destroy(1);
Validator
$v = $app->validator->make($_POST, [ 'name' => 'required|min:2|max:100|alpha', 'email' => 'required|email', 'password' => 'required|min:8', 'password_confirm' => 'required|confirmed:password', 'age' => 'nullable|integer|min:18', ]); if ($v->fails()) { $errors = $v->errors(); // all errors $firstEmail = $v->first('email'); // first error for a field } $v->throw(); // throws ValidationException on failure
Session & CSRF
$session = $app->sessionManager; $session->set('user_id', 42); $session->get('user_id'); $session->has('user_id'); $session->delete('user_id'); // Flash messages $session->flashSuccess('Profile saved.'); $session->flashError('Something went wrong.'); $messages = $session->getFlashMessages(); // CSRF $token = $session->generateCsrfToken(); $session->verifyCsrfToken($token); // true/false
Logger
$app->logger->info('User logged in', ['user_id' => 5]); $app->logger->warning('Slow query detected', ['ms' => 450]); $app->logger->error('Payment failed', ['order_id' => 99]); // Also: debug(), notice(), critical(), alert(), emergency()
Encryption
$enc = $app->encryption; $key = $enc->generateKey(); // 64-char hex key $ciphertext = $enc->encrypt('secret', $key); $plaintext = $enc->decrypt($ciphertext, $key); $hash = $enc->hashPassword('mypassword'); $enc->verifyPassword('mypassword', $hash); // true $token = $enc->randomBytes(32); // cryptographically secure token
Testing
# Run all tests (Unit + Feature + Database) php vendor/bin/phpunit # Run a specific suite php vendor/bin/phpunit --testsuite Unit php vendor/bin/phpunit --testsuite Feature php vendor/bin/phpunit --testsuite Database # Run network tests (requires internet connection) php vendor/bin/phpunit --group network
The test suite contains 327 tests and 499 assertions covering all framework components.
Documentation
Full documentation is available at jiframework.com.
Contributing
See CONTRIBUTING.md for guidelines.
License
MIT License — © 2025 Jahurul Islam
jahurul1/ji-framework 适用场景与选型建议
jahurul1/ji-framework 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 33 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「database」 「php」 「security」 「utilities」 「timezone」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jahurul1/ji-framework 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jahurul1/ji-framework 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jahurul1/ji-framework 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Dibi is Database Abstraction Library for PHP
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
A PSR-7 compatible library for making CRUD API endpoints
PHP module for MySql database
统计信息
- 总下载量: 33
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-26