Tempest PHP Framework

website·Indexed 33 days ago

https://tempestphp.com

A modern framework for PHP development featuring a built-in templating engine, attribute-based routing, and a comprehensive suite of features including a command bus, event bus, database component for SQLite, MySQL, and PostgreSQL, and an integrated container for dependency injection.

Tokens
130.5K
Snippets
802
Records
890
Agent score
66%

What's inside Tempest

  1. Overview of Tempest Discovery

    Discovery is Tempest's mechanism for automatically bootstrapping an application by scanning the codebase and detecting components to be loaded, eliminating the need for manual registration. It uses composer metadata to identify packages and application code, analyzing file names, attributes, interfaces, and return types to determine a component's purpose. For example, web routes are discovered via route attributes on controller methods.
    app/HomeController.php
    
    final readonly class HomeController
    {
        #[Get(uri: '/home')]
        public function __invoke(): View
        {
            return view('home.view.php');
        }
    }
  2. Overview of the Tempest PHP Framework

    Tempest is a modern PHP framework designed to maximize developer productivity by handling boilerplate for web and console applications. Its core philosophy is to 'get out of your way,' allowing developers to structure their projects (MVC, DDD, hexagonal, etc.) without forced conventions or heavy configuration. It aims to balance the robustness of Symfony with the eloquence of Laravel while remaining close to vanilla PHP.
  3. Overview of Tempest Discovery

    Discovery is Tempest's mechanism for bootstrapping applications by automatically scanning the codebase and detecting components (such as controller actions, event handlers, and console commands) that should be loaded. It is powered by composer metadata, including the application's own code and any package that depends on Tempest. Discovery uses rules based on file names, attributes, interfaces, and return types to determine a component's purpose.
    // Example: A web route discovered via the #[Get] attribute
    final readonly class HomeController
    {
        #[Get(uri: '/home')]
        public function __invoke(): View
        {
            return view('home.view.php');
        }
    }
  4. Overview of the Tempest PHP Framework

    Tempest is a modern PHP framework designed to minimize boilerplate and allow developers to focus on application code rather than framework configuration. It aims to provide a balance between the robustness of Symfony and the eloquence of Laravel, remaining lightweight and close to vanilla PHP while offering powerful features. A key characteristic is its flexibility regarding project structure; it supports MVC, DDD, hexagonal design, or microservices without requiring specific configuration.
  5. Overview of Tempest MCP

    Tempest's MCP component (currently experimental) implements the Model Context Protocol, enabling AI clients to interact with an application through tools, prompts, and resources. Servers are defined as classes annotated with #[McpServer] and are registered via discovery.
  6. Overview of tempest/markdown

    tempest/markdown is a high-performance PHP Markdown parser designed as an alternative to league/commonmark. Unlike regex-based parsers, it uses a single-pass approach that translates Markdown into tokens and then renders them to HTML, resulting in significantly lower memory usage and faster parsing times. It is designed to be feature-rich out-of-the-box while providing extension points for custom behavior.
  7. Overview of Tempest File Storage

    Tempest provides a unified interface to interact with various filesystems, including local storage and cloud providers like Amazon S3, Cloudflare R2, Azure, Google Cloud, and FTP. It is built on top of the Flysystem abstraction layer.
  8. Overview of Tempest File Storage

    Tempest provides a unified interface to interact with various filesystems, including local storage and cloud providers like Amazon S3, Cloudflare R2, Azure, and FTP. It is built on top of the Flysystem abstraction layer, allowing developers to use the same API regardless of the underlying storage provider.
  9. Overview of Tempest PHP Framework Philosophy

    Tempest is a community-driven, modern PHP framework designed to be lightweight and extensible. Its core philosophy centers on four pillars: embracing modern PHP features, providing a flexible project structure that does not force conventions (getting out of the developer's way), rethinking traditional framework patterns (thinking outside the box), and remaining community-driven.
  10. Inspect view component metadata via CLI

    You can retrieve metadata about discovered view components, including their file path, name, slots, and expected variables, using the hidden meta:view-component command.
    ./tempest meta:view-component [view-component]
  11. Understand the Tempest framework bootstrap process

    The Tempest framework boots using the FrameworkKernel. The process follows a specific sequence of operations to initialize the application environment:

    1. Entry Point: The process begins at either public/index.php or the ./tempest CLI binary.
    2. Discovery: The framework initiates discovery via the LoadDiscoveryLocations and LoadDiscoveryClasses classes.
    3. Configuration: Configuration files are registered using the LoadConfig class.
    4. Completion: Once bootstrapping is finished, the framework fires the Tempest\Core\KernelEvent::BOOTED event.

    Bootstrap classes are located within the Tempest\Core\Kernel namespace.

  12. Develop a package for Tempest

    To create a package for Tempest, add tempest/core as a dependency. Tempest uses automatic discovery via composer metadata to find and register discoverable classes. Unlike other frameworks, Tempest does not use a dedicated 'service provider' concept; instead, it relies on discovery and dependency initializers.