concept-labs / simple-http
(C)oncept-Labs Simple HTTP Application
Installs: 10
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 1
pkg:composer/concept-labs/simple-http
Requires
- php: >=8.2
- concept-labs/http: ^1
- concept-labs/http-session: ^1
This package is auto-updated.
Last update: 2026-02-16 11:22:34 UTC
README
A lightweight, modern PHP HTTP application framework built on PSR standards, designed to simplify web application development while maintaining flexibility and power.
🚀 Why Simple HTTP?
Simple HTTP provides a streamlined approach to building PHP web applications with:
- PSR-Compliant: Built on PSR-7 (HTTP Messages) and PSR-15 (HTTP Handlers) standards
- Easy Request Handling: Intuitive request/response abstractions with powerful handler system
- Flexible Layouts: Component-based layout system with template support
- Minimal Configuration: Get started quickly with sensible defaults
- Modern PHP: Requires PHP 8.2+ with full type safety and modern features
- Extensible: Plugin system and middleware support for customization
✨ Key Features
Powerful Request Handlers
- SimpleHandler: Abstract base for creating custom request handlers
- PageHandler: Specialized handler for page-based applications with layout support
- LayoutableHandler: Handler with integrated layout rendering capabilities
Flexible Response Building
Build responses with an elegant fluent API:
$handler->status(200) ->header('Content-Type', 'application/json') ->json(['message' => 'Success']);
Layout System
Component-based layout system with:
- Template rendering with PHTML templates
- Nested components and layouts
- Context management for template variables
- Plugin support for template transformations
Built-in Utilities
- JSON response helpers
- File download support
- Redirect helpers (including referer redirects)
- Header management utilities
📦 Installation
Install via Composer:
composer require concept-labs/simple-http
Requirements
- PHP 8.2 or higher
- Composer
🎯 Quick Start
Basic Handler Example
<?php use Concept\SimpleHttp\Handler\SimpleHandler; use Concept\SimpleHttp\Request\SimpleRequestInterface; class HelloWorldHandler extends SimpleHandler { public function act(SimpleRequestInterface $request): static { return $this->json([ 'message' => 'Hello, World!', 'timestamp' => time() ]); } }
Page Handler with Layout
<?php use Concept\SimpleHttp\Handler\PageHandler; use Concept\SimpleHttp\Request\SimpleRequestInterface; class HomePageHandler extends PageHandler { public function act(SimpleRequestInterface $request): static { $this->getLayout() ->setTemplate('page') ->setData('title', 'Welcome Home'); return $this; } }
JSON API Endpoint
<?php use Concept\SimpleHttp\Handler\SimpleHandler; use Concept\SimpleHttp\Request\SimpleRequestInterface; class ApiHandler extends SimpleHandler { public function act(SimpleRequestInterface $request): static { $data = [ 'status' => 'success', 'data' => ['id' => 1, 'name' => 'Example'] ]; return $this->status(200)->json($data); } }
📚 Documentation
Comprehensive technical documentation is available in the docs/ directory:
- Architecture Overview - System architecture and design principles
- Handler Guide - Complete guide to creating and using handlers
- Layout System - Layout and template system documentation
- API Reference - Detailed API documentation
- Configuration - Configuration options and setup
- Examples & Tutorials - Real-world examples and tutorials
🔧 Configuration
Simple HTTP uses a JSON-based configuration system. Configuration files are located in the etc/ directory:
sdi.json- Dependency injection configurationlayouts.json- Layout system configurationmiddleware.json- Middleware configurationconcept.json- Main application configuration
See the Configuration Guide for detailed information.
🤝 Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🔗 Related Projects
- concept-labs/http - Core HTTP library
- concept-labs/http-session - Session management
👨💻 Author
Viktor Halytskyi
Email: concept.galitsky@gmail.com
Built with ❤️ by Concept Labs