keyqcloud / kyte-php
Light-weight framework for developing versatile PHP applications.
Requires
- php: >=7.2
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- aws/aws-sdk-php: ^3.101
- stripe/stripe-php: ^7.2
Requires (Dev)
- dev-master
- v3.7.8
- v3.7.7
- v3.7.6
- v3.7.5
- v3.7.4
- v3.7.3
- v3.7.2
- v3.7.1
- v3.7.0
- v3.6.10
- v3.6.9
- v3.6.8
- v3.6.7
- v3.6.6
- v3.6.5
- v3.6.4
- v3.6.3
- v3.6.2
- v3.6.1
- v3.6.0
- v3.5.7
- v3.5.6
- v3.5.5
- v3.5.4
- v3.5.3
- v3.5.2
- v3.5.1
- v3.5.0
- v3.4.7
- v3.4.6
- v3.4.5
- v3.4.4
- v3.4.3
- v3.4.2
- v3.4.1
- v3.4.0
- v3.3.4
- v3.3.3
- v3.3.2
- v3.3.1
- v3.3.0
- v3.2.9
- v3.2.8
- v3.2.7
- v3.2.6
- v3.2.5
- v3.2.4
- v3.2.3
- v3.2.2
- v3.2.1
- v3.2.0
- v3.1.1
- v3.1.0
- v3.0.90
- v3.0.89
- v3.0.88
- v3.0.87
- v3.0.86
- v3.0.85
- v3.0.84
- v3.0.83
- v3.0.82
- v3.0.81
- v3.0.80
- v3.0.79
- v3.0.78
- v3.0.77
- v3.0.76
- v3.0.75
- v3.0.74
- v3.0.73
- v3.0.72
- v3.0.71
- v3.0.70
- v3.0.69
- v3.0.68
- v3.0.67
- v3.0.66
- v3.0.65
- v3.0.64
- v3.0.63
- v3.0.62
- v3.0.61
- v3.0.60
- v3.0.59
- v3.0.58
- v3.0.57
- v3.0.56
- v3.0.55
- v3.0.54
- v3.0.53
- v3.0.52
- v3.0.51
- v3.0.50
- v3.0.49
- v3.0.48
- v3.0.47
- v3.0.46
- v3.0.45
- v3.0.44
- v3.0.43
- v3.0.42
- v3.0.41
- v3.0.40
- v3.0.39
- v3.0.38
- v3.0.37
- v3.0.36
- v3.0.35
- v3.0.34
- v3.0.33
- v3.0.32
- v3.0.31
- v3.0.30
- v3.0.29
- v3.0.28
- v3.0.27
- v3.0.26
- v3.0.25
- v3.0.24
- v3.0.23
- v3.0.22
- v3.0.21
- v3.0.20
- v3.0.19
- v3.0.18
- v3.0.17
- v3.0.16
- v3.0.15
- v3.0.14
- v3.0.13
- v3.0.12
- v3.0.11
- v3.0.10
- v3.0.9
- v3.0.8
- v3.0.7
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- 2.1.x-dev
- v2.0.0
- v1.0.0
- dev-issue-57
- dev-issue-12
- dev-issue-72
- dev-issue-11
- dev-60-feature-code-refactoring-and-optimization-of-api-class
- dev-issue-47
- dev-issue-38
This package is auto-updated.
Last update: 2025-08-11 07:45:10 UTC
README
(c) 2020-2025 KeyQ, Inc.
About Kyte-PHP
Kyte-PHP is a modern, database-driven web application framework designed to make development more enjoyable and streamline the development workflow. The framework works as a backend API and can be integrated into different application architectures and front-end languages/frameworks.
Key Features:
- Dynamic MVC Architecture: Models, views, and controllers are managed through Kyte Shipyard and stored in the database
- Multi-tenant SaaS Support: Built-in support for multi-tenant applications with account-level scoping
- API-First Design: RESTful API with HMAC signature authentication
- Database-Driven Configuration: Application models and controllers are dynamically loaded from the database
- AWS Integration: Native support for S3, SES, SNS, and other AWS services
- Session Management: Robust session handling with configurable timeouts and multi-login support
Architecture Overview
Kyte-PHP has evolved from a traditional file-based MVC framework to a dynamic, database-driven architecture. All application models, controllers, and configurations are now managed through Kyte Shipyard and stored in the database, allowing for:
- Runtime model and controller loading
- Dynamic application configuration
- Multi-application support from a single framework instance
- Version-controlled deployments through the database
Getting Started
Prerequisites
- PHP 7.4 or higher
- MySQL 5.7+ or MariaDB 10.2+
- Composer
- Kyte Shipyard
- AWS account
Installation
composer require keyqcloud/kyte-php
Basic Setup
- Configure your web server with the following
.htaccess
:
FallbackResource /index.php
- Database Configuration - Set your database credentials in your configuration:
define('KYTE_DB_HOST', 'your-db-host'); define('KYTE_DB_DATABASE', 'your-db-name'); define('KYTE_DB_USERNAME', 'your-db-user'); define('KYTE_DB_PASSWORD', 'your-db-password'); define('KYTE_DB_CHARSET', 'utf8mb4');
- Initialize the API in your
index.php
:
<?php require_once 'vendor/autoload.php'; $api = new \Kyte\Core\Api(); $api->route(); ?>
Authentication & API Access
API Signature Generation
Kyte-PHP uses HMAC-SHA256 signatures for secure API access. Signature are automatically generate or can be requested using platform specific libraries. Kyte currently supports vanilla JS, Dart/Flutter, C/C++, Java, and Python. Below is a list of platform specific libraries:
- JavaScript
- Python
- Swift
- Dart/Flutter
- Java
- C++
- C (Pending QA)
- Node.js (Pending QA)
- Go (Pending QA)
- PHP
Making API Calls
Once you have a signature, use the following URL format:
- POST
/{model}
+ data (Create) - PUT
/{model}/{field}/{value}
+ data (Update) - GET
/{model}/{field}/{value}
(Read) - DELETE
/{model}/{field}/{value}
(Delete)
Required headers:
X-Kyte-Identity
: Base64 encoded identity stringX-Kyte-Signature
: HMAC signatureX-Kyte-AppId
: Application identifier (for multi-tenant apps)
Dynamic Model System
Database-Driven Models
Models are now stored in the DataModel
table and dynamically loaded:
// Models are automatically loaded from the database // No need to define them in files anymore $user = new \Kyte\Core\ModelObject(constant('User')); $user->create([ 'name' => 'John Doe', 'email' => 'john@example.com' ]);
Model Structure
Models follow this structure in the database:
[ 'name' => 'ModelName', 'struct' => [ 'field_name' => [ 'type' => 's|i|d|t|b', // string, integer, decimal, text, blob 'required' => true|false, 'size' => 255, 'date' => true|false, 'protected' => true|false, 'fk' => [ 'model' => 'RelatedModel', 'field' => 'id' ] ] ] ]
Supported Field Types
Type | Description | MySQL Type |
---|---|---|
s |
String | VARCHAR |
i |
Integer | INT |
bi |
Big Integer | BIGINT |
d |
Decimal | DECIMAL |
t |
Text | TEXT |
tt |
Tiny Text | TINYTEXT |
mt |
Medium Text | MEDIUMTEXT |
lt |
Long Text | LONGTEXT |
b |
Blob | BLOB |
Controllers
Dynamic Controller Loading
Controllers are stored in the Controller
table and loaded dynamically:
class CustomController extends \Kyte\Mvc\Controller\ModelController { protected function init() { // Custom initialization $this->requireAuth = true; $this->allowableActions = ['get', 'new', 'update']; } public function hook_preprocess($method, &$data, &$obj = null) { // Custom preprocessing logic if ($method === 'new') { $data['created_by'] = $this->api->user->id; } } }
Controller Hooks
Available hooks for customizing behavior:
hook_init()
- Initialize controller settingshook_auth()
- Custom authentication logichook_prequery()
- Modify query parametershook_preprocess()
- Process data before operationshook_response_data()
- Modify response datahook_process_get_response()
- Process GET responses
Multi-Tenant Applications
Kyte-PHP supports multi-tenant architectures:
// Application-level models with org scoping $this->api->app->org_model; // Organization model $this->api->app->userorg_colname; // User-organization relationship // Automatic scoping in controllers if ($this->api->app->org_model !== null) { $conditions = [ ['field' => $this->api->app->userorg_colname, 'value' => $this->user->organization_id] ]; }
Database Features
SSL/TLS Support
Configure SSL connections with:
define('KYTE_DB_CA_BUNDLE', '/path/to/rds-ca-2019-root.pem');
Connection Management
- Automatic connection switching between main and application databases
- Connection pooling and management
- Fallback support for non-SSL connections
Advanced Features
Environment Variables
Application-level environment variables stored in KyteEnvironmentVariable
and managed through Kyte Shipyard:
// Access app-specific environment variables $envVars = KYTE_APP_ENV; echo $envVars['CUSTOM_SETTING'];
AWS Integration
Built-in support for:
- S3: File storage and static website hosting
- SES: Email sending capabilities
- SNS: Notification services
- CloudFront: CDN distribution
Configuration Options
Framework Constants
define('DEBUG', false); define('ALLOW_MULTILOGON', false); define('SESSION_TIMEOUT', 3600); define('SIGNATURE_TIMEOUT', 300); define('PAGE_SIZE', 50); define('STRICT_TYPING', true);
Date Formatting
define('APP_DATE_FORMAT', 'Y-m-d H:i:s');
Error Handling
Comprehensive error handling with:
- Session exceptions for authentication errors
- Database connection error recovery
- Application-level error logging
- S3-based error logging for production
Migration from Earlier Versions
If migrating from file-based models:
- Use Kyte Shipyard to import existing models
- Convert file-based controllers to database entries
- Update application configuration for multi-tenant support
- Test dynamic loading functionality
API Response Format
Standard API responses:
{ "response_code": 200, "session": "session_token", "token": "transaction_token", "uid": "user_id", "model": "ModelName", "transaction": "GET|POST|PUT|DELETE", "txTimestamp": "1640995200", "data": [], "page_size": 50, "page_num": 1, "total_count": 100, "total_filtered": 75 }
Development Tools
Kyte Shipyard Integration
All model and controller management is now done through Kyte Shipyard:
- Visual model designer
- Controller code editor
- Application deployment management
- Environment variable configuration
CLI Support
The framework includes CLI support for:
- Database migrations
- Model synchronization
- Application deployment
Security
- HMAC-SHA256 signature authentication
- SQL injection prevention with prepared statements
- Cross-origin resource sharing (CORS) support
- Session token validation
- Protected field support for sensitive data
Performance
- Connection pooling
- Prepared statement caching
- Efficient foreign key loading
- Pagination support for large datasets
- Optional external table loading
License
Copyright (c) 2020-2025 KeyQ, Inc. All rights reserved.