stormmore/framework

There is no license information available for the latest version (dev-main) of this package.

dev-main 2025-09-20 20:09 UTC

This package is auto-updated.

Last update: 2025-09-20 20:09:42 UTC


README

Built with love to deliver joy and satisfaction with every piece of code you write. StormPHP is designed to be intuitive, lightweight, and blazing fast โ€” the simplest app takes just 4 lines of code.

Despite its minimal footprint (~100KB, zero dependencies), it provides a rich set of features to help you build modern PHP applications.

โœจ Features

  • Easy to learn โ€” start coding in minutes
  • Tiny footprint (~100KB, no dependencies)
  • Blazing fast
  • Built-in Dependency Injection Container
  • Built-in Middleware Pipeline
  • Command Query Separation (CQS)
  • Event Dispatcher
  • Multilingual (i18n) support
  • Authentication & Authorization
  • Logger
  • Autoloader with class scanning
  • Path alias system (@templates/homepage.php)
  • Mature PHP-based view system (layouts, child views, CSS/JS injection)
  • Validation & Forms
  • Mailing (i18n, SMTP client)
  • CLI tasks & controller execution
  • End-to-end tests via PHPUnit
  • Error customization
  • Docker ready
  • PHP 8+ support
  • Works with StormPHP Queries

๐Ÿš€ Hello World

require 'vendor/autoload.php';

$app = App::create();
$app->addRoute('/', fn() => "Hello, world!");
$app->run();

โšก Quick Start

Installation

Composer

composer require stormmore/framework

In your index.php:

require '../vendor/autoload.php';

Standalone

Download the ZIP package, extract src/, and include the autoloader:

require 'YOUR/PATH/TO/STORM/src/autoload.php';

๐Ÿ“‚ Project Structure

A typical application layout:

my_app/
โ”œโ”€โ”€ .cache/         # cached metadata
โ”œโ”€โ”€ .logs/          # log files
โ”œโ”€โ”€ public_html/    # public web root
โ”‚   โ”œโ”€โ”€ index.php
โ”‚   โ”œโ”€โ”€ app.css
โ”‚   โ””โ”€โ”€ app.js
โ”œโ”€โ”€ src/            # application source
โ”‚   โ”œโ”€โ”€ MyController.php
โ”‚   โ”œโ”€โ”€ Database.php
โ”‚   โ””โ”€โ”€ templates/
โ”‚       โ””โ”€โ”€ view.php
โ””โ”€โ”€ README.md

๐Ÿ›  Key Concepts

Class Scanning

Storm automatically scans your src/ directory for controllers, tasks, and classes. In production, it uses a .cache file for performance.

Autoloading

Namespaces map directly to file paths:

use Infrastructure\Images\Resize;

โ†’ loads src/infrastructure/images/resize.php.

Routing

Controllers are discovered automatically via the #[Route] attribute. No manual registration required.

Middleware

Every request flows through a middleware pipeline. You can plug in your own middleware at any stage.

Aliases

Aliases make path management easier:

$app->addMiddleware(AliasMiddleware::class, [
    '@templates' => "@/src/templates"
]);

Configuration

Optional but recommended for larger apps:

$app = App::create(directories: [
  'project' => '../',
  'source'  => '../src',
  'cache'   => '../.cache',
  'logs'    => '../.logs'
]);

๐ŸŽฎ Example Controller

namespace App;

use Stormmore\Framework\Mvc\Attributes\Controller;
use Stormmore\Framework\Mvc\Attributes\Route;
use Stormmore\Framework\Mvc\View\View;

#[Controller]
readonly class HomepageController
{
    #[Route("/")]
    public function index(): View
    {
        return view("@templates/homepage");
    }
}

Supports:

  • Dependency Injection (via constructor)
  • HTTP Methods: #[Get], #[Post], #[Put], #[Delete]
  • Query & Path Parameters
  • Responses: View, Redirect, JSON objects, primitives

๐ŸŽจ Views

Storm views are plain PHP files, but with helpers for layouts, assets, and dynamic rendering.

Layout Example:

<!DOCTYPE html>
<html>
<head>
    <?php $view->printCss(); ?>
    <?php $view->printJs(); ?>
    <?php $view->printTitle("StormApp"); ?>
</head>
<body>
    <main>
        <?php print_view("@templates/includes/header"); ?>
        <?= $view->content ?>
    </main>
</body>
</html>

Template Example:

<?php $view->useLayout('@templates/includes/layout'); ?>

<h2>Success!</h2>
It's your first template.

๐ŸŒ Internationalization (i18n)

Enable multilingual support:

$app->addMiddleware(LanguageMiddleware::class);

Example config (settings.ini):

i18n.multi_language = true
i18n.default_language = en-US
i18n.languages = en-US, fr-FR, de-DE, pl-PL
i18n.cookie.name = locale
i18n.translation.file_pattern = @/src/lang/%file%.ini
i18n.culture.file_pattern = @/src/lang/culture/%file%.ini

๐Ÿ“– Documentation

StormPHP is designed to feel natural and intuitive, but you can explore more in-depth examples and guides in the docs (coming soon).

๐Ÿ’ก Roadmap

  • Example app repo
  • CI/CD integration
  • Advanced documentation website

โš–๏ธ License

StormPHP is open-source under the MIT License.

๐Ÿ‘‰ Teraz pytanie do Ciebie: chcesz ลผebym przygotowaล‚ od razu wersjฤ™ Markdown z gotowymi badgeโ€™ami (build, PHP version, Packagist, license) do wklejenia na GitHuba?