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

1.3.1 2025-10-25 11:19 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:

🔧 Configuration

Simple HTTP uses a JSON-based configuration system. Configuration files are located in the etc/ directory:

  • sdi.json - Dependency injection configuration
  • layouts.json - Layout system configuration
  • middleware.json - Middleware configuration
  • concept.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

👨‍💻 Author

Viktor Halytskyi
Email: concept.galitsky@gmail.com

Built with ❤️ by Concept Labs