PHPackages                             pavex/website - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. pavex/website

ActiveLibrary

pavex/website
=============

Pavex website controller, router and presenter engine. PHP 8.0+.

00PHP

Since Jun 11Pushed 1mo agoCompare

[ Source](https://github.com/pavex/website)[ Packagist](https://packagist.org/packages/pavex/website)[ RSS](/packages/pavex-website/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Pavex Website
=============

[](#pavex-website)

**The high-performance, SEO-centric PHP 8.0+ engine for developers who demand maximum control and zero bloat.**

[![PHP Version](https://camo.githubusercontent.com/ff50be78d3b99914588d6f8fc98d72b22c60659b5fc7ae5e6528ad6c9a41dba3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e302d3838393262662e737667)](https://php.net)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

---

🌟 Philosophy: Beyond "Just Another Framework"
---------------------------------------------

[](#-philosophy-beyond-just-another-framework)

Pavex Website isn't a general-purpose application framework. It is a specialized, opinionated **Website Engine**.

In an era where web performance and Core Web Vitals directly impact business success, Pavex Website strips away the heavy abstractions of traditional MVC frameworks. It provides a surgical toolset for building content-driven sites that are lightning-fast, easy to maintain, and perfectly optimized for search engines from day one.

### The "Website-First" Approach

[](#the-website-first-approach)

While other frameworks treat a "website" as a simplified "web app," Pavex Website acknowledges that websites have unique requirements:

- **Instant Response Times:** Minimal overhead between the request and the response.
- **Semantic Integrity:** Total control over every byte of HTML output.
- **Dynamic SEO:** First-class support for canonicals, meta tags, and structured data.
- **Bi-directional Clarity:** Routing that is as easy to read as it is to write.

---

Why Choose this package.
------------------------

[](#why-choose-this-package)

- **Extreme Performance:** No heavy DI containers, no complex middleware stacks, no bloated ORM. Just raw PHP speed with a refined architectural structure.
- **SEO Mastery:** Integrated `PageContext` makes managing complex SEO requirements (canonicals, OpenGraph, lang attributes, breadcrumbs) a part of your natural workflow, not an afterthought.
- **Pure PHP Templates:** Forget learning yet another template syntax like Blade or Twig. Use pure PHP for logic and template inheritance that is both powerful and transparent.
- **Integrity by Design:** Strict property visibility rules (Public for route args, Protected for templates) prevent common state-leakage bugs and make your code self-documenting.
- **Smart Reverse Routing:** Change a URL pattern in one place, and every link across your entire site updates automatically. No more broken internal links.

---

🛠️ What Can You Build?
----------------------

[](#️-what-can-you-build)

Pavex Website is the ideal foundation for:

- **Corporate Portals:** Fast, accessible, and professional brand presences.
- **Content Magazines &amp; Blogs:** SEO-optimized platforms for publishers.
- **Marketing Landing Pages:** High-conversion pages with no technical debt.
- **Product Showcases:** Visually rich frontends backed by a clean data layer.
- **E-commerce Frontends:** Performance-critical storefronts for modern shops.

---

🏗️ Core Architecture
--------------------

[](#️-core-architecture)

The framework operates on three primary components:

1. **Router:** Maps URLs to Presenters (Input) and Presenters back to URLs (Output).
2. **Presenter:** The "Controller". It prepares data, manages SEO metadata, and triggers rendering.
3. **Control:** The orchestrator. It handles the request/response lifecycle and dependency injection.

---

🚦 Getting Started
-----------------

[](#-getting-started)

### 1. Installation

[](#1-installation)

```
composer require pavex/website
```

### 2. Recommended Directory Structure

[](#2-recommended-directory-structure)

```
src/
  Website/
    Application.php           # App bootstrapper
    ApplicationContainer.php  # Service locator
    Presenter/
      BasePresenter.php       # Shared logic (SEO, common data)
      HomePresenter.php       # Your first page
      templates/
        base.php              # Main layout
        home.php              # Page template
    Router/
      WebsiteRules.php        # Route definitions

```

### 3. Creating a Presenter

[](#3-creating-a-presenter)

The presenter lifecycle centers around the `render()` method.

```
namespace App\Website\Presenter;

use Pavex\Website\Presenter;

final class HomePresenter extends BasePresenter
{
    // Public properties are automatically injected from route arguments
    public string $section = 'default';

    // Protected properties are available in the template via $this
    protected array $features = [];

    public function render(): ?string
    {
        // 1. Prepare SEO metadata
        $this->context->title = 'Welcome to My Website';
        $this->context->description = 'Building fast websites with Pavex.';
        $this->context->canonical = $this->link($this);

        // 2. Prepare data for template
        $this->features = ['Speed', 'Simplicity', 'SEO'];

        // 3. Trigger rendering (MANDATORY)
        return parent::render();
    }
}
```

### 4. Creating a Template

[](#4-creating-a-template)

Templates are located in the `templates/` subdirectory relative to the Presenter.

```
// templates/home.php
