Download the PHP package gemvc/library without Composer
On this page you can find all versions of the php package gemvc/library. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gemvc/library
More information about gemvc/library
Files in gemvc/library
Informations about the package library
🚀 GEMVC
Transform your PHP development with GEMVC - a modern PHP framework where security meets simplicity! Build professional, secure APIs in minutes, not hours.
📋 Table of Contents
- Installation
- Quick Start
- Getting Started Guide
- Key Components
- Architecture Overview
- Why GEMVC Stands Out
- Security Features
- Error Handling
- JWT Authentication
- Dual Server Support
- Real-Time Communication
- Developer Experience
- Automatic Table Generator
- Table Database Abstraction
- Core Features
- Requirements
- Perfect For
- Documentation
- About
🔥 5-Second Installation
Initialize Your Project
After installing the library, initialize your project with:
This script will:
- Create the necessary directory structure (
/app
,/app/api
,/app/controller
,/app/model
,/app/table
) - Generate a sample
.env
file with default configuration - Copy appropriate startup files to your project root based on platform choice
- Set up local command wrappers
Note: If the above command doesn't work, check if the path exists. The script may be located at
vendor/gemvc/library/init.php
depending on your installation method.
Generate Complete API Services
GEMVC includes a powerful CLI command for generating complete API services with a single command:
This command automatically generates:
- API Service (
app/api/User.php
) - Handling requests with validation and routing - Controller (
app/controller/UserController.php
) - Processing business logic - Model (
app/model/UserModel.php
) - Managing data logic - Table (
app/table/UserTable.php
) - Database abstraction layer
The generated code includes complete CRUD operations with proper validation, error handling, and documentation, following GEMVC's layered architecture pattern.
⚡ Performance Powerhouse
The Ultimate Performance Trio: OpenSwoole + DB Cache + Connection Pooling
GEMVC combines three powerful technologies to deliver exceptional performance:
Performance Benefits:
-
OpenSwoole
- Non-blocking I/O for concurrent requests
- Coroutine support for efficient resource usage
- Built-in HTTP/WebSocket server
- Automatic worker process management
-
Database Cache
- Automatic caching of frequent queries
- Configurable TTL for cache freshness
- Memory-efficient cache size limits
- Automatic cache invalidation
- Connection Pooling
- Reuse database connections
- Automatic connection health checks
- Configurable pool sizes per worker
- Efficient resource management
Real-World Impact:
Configuration Example:
This powerful combination makes GEMVC perfect for:
- High-traffic APIs
- Real-time applications
- Microservices
- Data-intensive applications
- WebSocket servers
🚀 Quick Start
1. Configure Your Magic
Create an .env
file in your app directory:
2. Start Building Your API
📘 Getting Started Guide
Create a complete API endpoint with authentication, validation, and error handling:
🧩 Key Components
Component | Description | Key Features |
---|---|---|
Database | SQL query building & execution | Type-safe queries, injection protection, table generation, ORM capabilities |
HTTP | Request/response handling | Validation, auth, WebSockets |
Security | Security features | Encryption, sanitization, protection |
Helpers | Utility classes | File, image, type handling |
WebSocket | Real-time communication | Redis scaling, heartbeat, channels |
🏗️ Architecture Overview
Elegant Database Queries
Database Components Hierarchy
In this architecture:
-
Table extends PdoQuery to provide a fluent, object-oriented interface for working directly with database tables. It inherits all query capabilities while adding table-specific operations like insertSingleQuery, updateSingleQuery, and type mapping.
-
PdoQuery extends QueryExecuter to add higher-level database operations like SELECT, INSERT, UPDATE, and DELETE queries while inheriting the core query execution capabilities.
-
QueryExecuter aggregates PdoConnection to execute SQL queries while benefiting from connection pooling. It implements lazy loading, only establishing a database connection when actually needed for query execution.
- PdoConnection manages database connections with advanced pooling features, including connection reuse, health verification, automatic expiration, and efficient resource tracking.
This layered design allows each class to focus on a specific responsibility while building on the capabilities of its parent classes, resulting in a powerful and flexible database interaction system.
Enhanced QueryBuilder System
The QueryBuilder system has been improved with:
- Non-static query building methods for better encapsulation and state management
- QueryBuilderInterface implementation in query classes (Select, Insert, Update, Delete)
- Error tracking mechanism that allows QueryBuilder to store the last executed query's error
- getError() method for consistent error retrieval across all query operations
These improvements enhance error handling and provide more robust debugging capabilities. With the enhanced error handling, you can now easily identify and resolve database query issues:
🌟 Why GEMVC Stands Out
🛡️ Security Features
Use Case: Securely handle sensitive file uploads with minimal code and maximum protection.
🔄 Robust Error Handling
Use Case: Build APIs with consistent error responses that provide clear messages to clients.
🔑 Built-in JWT Authentication
Use Case: Implement secure, role-based API authentication with minimal boilerplate code.
🔀 Dual Server Support
Use Case: Start with traditional Apache/Nginx setup, then easily scale to high-performance OpenSwoole when needed without code changes.
OpenSwoole/Swoole Compatibility
GEMVC now provides seamless compatibility with both OpenSwoole and regular Swoole extensions:
- Dynamic extension detection - Automatically detects whether OpenSwoole or Swoole is installed
- Runtime instance checking - Uses proper class references without IDE warnings
- Generic object type hints - Maintains code clarity while ensuring runtime validation
- Clear error messages - Provides helpful feedback when neither extension is available
This compatibility layer ensures your application works smoothly regardless of which extension is installed on your server.
Implementation details:
🔄 Real-Time Communication
Use Case: Build real-time chat applications, notifications, or live dashboards with automatic scaling across servers.
📚 Table Database Abstraction
Use Case: Work directly with database tables through a typed, fluent interface. The Table class provides database abstraction - a proper Model layer will be added in the future.
🏗️ Automatic Table Generator
Use Case: Automatically generate and maintain database tables from your Table classes with indexes, constraints, and validation, eliminating manual SQL schema creation and migration scripts.
👨💻 Developer Experience
⚡ Lightning-Fast Development
🤖 AI-Ready Framework
- Dual AI Support:
AIAssist.jsonc
: Real-time AI coding assistanceGEMVCLibraryAPIReference.json
: Comprehensive API documentation
- Smart Code Completion: AI tools understand our library structure
- Intelligent Debugging: Better error analysis and fixes
- Future-Ready: Ready for emerging AI capabilities
🎈 Lightweight & Flexible
- Minimal Dependencies: Just 3 core packages
- Zero Lock-in: No rigid rules or forced patterns
- Cherry-Pick Features: Use only what you need
- Framework Agnostic: Works with any PHP project
- Server Agnostic: Same code works on Apache and OpenSwoole
Use Case: Rapidly prototype and build new features with minimal boilerplate code and maximum productivity.
💪 Core Features
🏗️ Modern Architecture
- Type Safety: PHP 8.0+ features
- Modular Design: Clear separation of concerns
- Smart Patterns: Factory, Builder, Traits
- Clean Structure: Intuitive organization
- Consistent Naming: camelCase conventions throughout
🔋 Efficient Resource Management
- Lazy Database Connections: Connections only established when actually needed
- Model Efficiency: Table and model classes can be instantiated without database overhead
- Advanced Connection Pooling: Sophisticated connection management with:
- Parameter-based connection sharing
- Automatic connection health verification
- Time-based connection expiration
- Configurable pool sizes
- Efficient resource tracking
- Automatic Cleanup: Resources properly released through destructors
- Memory Optimization: Smart image processing
🖥️ Server Flexibility
- Apache/Nginx Support: Traditional PHP request handling
- OpenSwoole Support: High-performance asynchronous server
- Unified Request Interface: Same code, different environments
- Server-Specific Optimizations: Get the best from each platform
- Platform-specific Components: SwooleBootstrap and SwooleApiService for Swoole compatibility
- CLI Platform Selection: Easy switching between Apache and Swoole with
gemvc setup [apache|swoole]
🛡️ Security Features
- Input Sanitization: Automatic XSS prevention
- Query Protection: SQL injection prevention
- File Security: Path traversal protection
- Email Safety: Content security validation
- WebSocket Protection: Rate limiting and authentication
- Robust Error Handling: Consistent error responses with appropriate status codes
📊 Database & ORM Features
- Query Builder: Intuitive database operations with automatic parameter binding
- Table Class: Database abstraction layer with typed properties and fluent query interface
- Table Generator: Create tables from PHP objects using reflection
- Schema Management: Add indexes, constraints, and relationships
- Type Mapping: Automatic conversion between PHP and SQL types
- Transaction Support: All operations wrapped in transactions
- Column Constraints: Support for NOT NULL, DEFAULT values, and CHECK constraints
📡 Real-Time Communication
- WebSocket Support: Built-in OpenSwoole integration
- Channel Messaging: Pub/Sub pattern for group communication
- Connection Management: Automatic heartbeat and cleanup
- Horizontal Scaling: Redis integration for multi-server deployments with TTL-based memory management
- Request Integration: Same validation and authentication as REST APIs
- Graceful Fallbacks: Automatic local storage if Redis is unavailable
🎯 Developer Tools
- Query Builder: Intuitive database operations
- File Processing: Secure file handling with encryption
- Image Handling: WebP conversion and optimization
- Type System: Comprehensive validation
- Value Extraction: Type-safe methods for validated data access
- CLI Tools: Command-line utilities for project setup and service generation
⚡ Performance
- Connection Pooling: Smart database connections
- Resource Management: Efficient file streaming
- Memory Optimization: Smart image processing
- Query Optimization: Built-in performance features
- WebSocket Efficiency: Optimized for high-concurrency applications
- Async Operations: Non-blocking I/O with OpenSwoole
- File Preloading: Production mode file preloading for Swoole
📊 Feature Comparison
Feature | Traditional Approach | GEMVC Approach |
---|---|---|
Database Queries | Manual SQL strings, manual binding | Type-safe QueryBuilder, automatic binding |
Table Interaction | Manual object mapping to database | Typed Table class with automatic conversion |
Schema Management | Manual SQL CREATE TABLE statements | Automatic table generation from PHP objects |
Error Handling | Inconsistent error responses | Standardized responses with proper status codes |
Authentication | Manual token parsing, unclear errors | Built-in JWT handling with specific error responses |
WebSockets | Manual implementation, no scaling | Ready-to-use handler with Redis scaling |
File Handling | Manual validation, no encryption | Built-in validation, one-line encryption |
Server Support | Either Apache OR Swoole | Same code on BOTH platforms |
Platform Selection | Manual configuration | Simple CLI command: gemvc setup [apache|swoole] |
📋 Requirements
- PHP 8.0+
- PDO Extension
- OpenSSL Extension
- GD Library
- OpenSwoole Extension (optional, for high-performance server and WebSockets)
- Redis Extension (optional, for WebSocket scaling)
🎯 Perfect For
- Microservices: Specific, efficient functionality
- Legacy Projects: Add modern features
- New Projects: Full control from day one
- Learning: Clear, understandable code
- Real-Time Apps: Chat, notifications, live updates
- High-Load Applications: Scale with OpenSwoole when needed
📚 Documentation
Want to dive deeper? Check out our Documentation.md
About
Author: Ali Khorsandfard [email protected]
GitHub: secure73/gemvc
License: MIT
Made with ❤️ for developers who love clean, secure, and efficient code.