lopatar/php-sdkv2

Second generation of my experimental PHP SDK!

v3.2.1 2025-07-15 09:10 UTC

README

Powerful PHP framework, written in PHP 8.4, modernised version of rather primitive PHP SDK (which is now archived).

Currently trying to stay in line with current PHP updates.

Requirements

  • PHP 8.4
  • Composer
  • Web server (routing all requests to public/index.php)

Installation

To install the SDK, there are two ways.

Skeleton project

To use the skeleton project run the following composer command.

composer create-project lopatar/php-sdkv2-skeleton <PROJECT-NAME>

Manual installation

composer require "lopatar/php-sdkv2"
  • Create following directory structure in the folder where the "vendor" folder resides

    • App
      • Controllers (where your controller files reside)
      • Views (where your view files reside)
      • Models (where your model files reside)
  • Map the App namespace in composer.json like so

{
  "autoload": {
    "psr-4": {
      "App\\": "App/"
    }
  }
}
  • Create your configuration class

  • Done!

Routing requests to index.php

  • NGINX
    root /path/to/public;
    index index.php;

    location / {
        try_files $uri /index.php$is_args$args =404;
    }

Recommended plugins

Configuration class

The App object expects an instance of IConfig passed to the constructor, please create your class such as:

<?php
final class Config implements \Sdk\IConfig
{

}

Features

  • Request object
    • URL management
    • Cookie management
      • Cookies can be automatically encrypted & decrypted using AES-256-CBC
    • Headers, GET, POST, SERVER variables management
  • Response object
    • View system (injecting PHP variables into HTML code)
    • Status code, body (writing, flushing) management
  • Routing
    • Anonymous callbacks / ControllerName::methodName
    • URL parameters (type validation, min & max value (length for strings), escaping)
  • Middleware (can be used on specific Routes or the App object)
    • IMiddleware interface (used to define your own middleware)
    • Session middleware, used storing data across requests
    • CSRF middleware, used to protect against CSRF attacks
    • HttpBasicAuth middleware, used for basic HTTP auth, compares passwords hashed using password_hash
    • Redirect middleware, useful for redirecting right in the request processing chain.
  • Database connectors
  • Utilities namespace
  • Structures namespace
    • Stack Fixed size stack implementation allowing mixed data type values
    • Queue Fixed size queue implementation allowing mixed data type values
  • Config object