PHPackages                             pcp/pcp - 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. [Templating &amp; Views](/categories/templating)
4. /
5. pcp/pcp

ActiveLibrary[Templating &amp; Views](/categories/templating)

pcp/pcp
=======

PCP (PHP Components Preprocessor) — a component-based view engine for PHP

v0.0.1-alpha.0(1w ago)00MITPHPPHP ^8.4CI failing

Since Mar 9Pushed 1w agoCompare

[ Source](https://github.com/StarDragonStudios/pcp)[ Packagist](https://packagist.org/packages/pcp/pcp)[ Docs](https://github.com/pcp-engine/pcp)[ RSS](/packages/pcp-pcp/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (2)Used By (0)

[![Tests](https://github.com/StarDragonStudios/pcp/actions/workflows/tests.yml/badge.svg)](https://github.com/StarDragonStudios/pcp/actions/workflows/tests.yml/badge.svg)[![Packagist Version](https://camo.githubusercontent.com/989d193c1c0d176d14c076ff9c029a94a3e0f9c0dd82ef376f11fb97c5d1c5b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7063702f706370)](https://camo.githubusercontent.com/989d193c1c0d176d14c076ff9c029a94a3e0f9c0dd82ef376f11fb97c5d1c5b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7063702f706370)[![License](https://camo.githubusercontent.com/39404af6f398b86238da9f93d6fdeca2d382b6f79c67c95389e2dbd57f7c6a57/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f53746172447261676f6e53747564696f732f706370)](https://camo.githubusercontent.com/39404af6f398b86238da9f93d6fdeca2d382b6f79c67c95389e2dbd57f7c6a57/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f53746172447261676f6e53747564696f732f706370)

PCP — Preprocessed Component Pages
==================================

[](#pcp--preprocessed-component-pages)

PCP is a component-based templating system for PHP inspired by modern UI frameworks like React, but compiled to pure PHP.

It introduces a JSX-like syntax that compiles into efficient PHP code using an AST-based compiler.

⚠️ **Status:** Alpha (`v0.0.1-alpha.0`)
The API and syntax may change.

---

Philosophy
==========

[](#philosophy)

PCP aims to bring modern component composition to PHP while keeping the runtime extremely small.

Key ideas:

- compile-time transformations
- minimal runtime
- component-first design
- explicit composition

Instead of interpreting templates at runtime, PCP **compiles components to native PHP**.

---

Example
=======

[](#example)

Component
---------

[](#component)

```
namespace App\Components;

use PCP\Component;
use PCP\Runtime\Node;

final class Card extends Component
{
    public function __construct(
        private ?Node $header = null,
        private ?Node $body = null,
        private ?Node $footer = null,
    ) {
        parent::__construct();
    }

    public function render(): Node
    {
        return (

        );
    }
}

```

Usage
-----

[](#usage)

```

    Hello
    Content
    Footer

```

---

Slots
=====

[](#slots)

PCP uses **named node props** instead of runtime slot resolution.

Provide content:

```
...

```

Consume content:

```

```

Compilation result:

```
new Card(
    header: Runtime::fragment([...]),
    body: Runtime::fragment([...]),
    footer: Runtime::fragment([...])
);
```

---

Features (alpha)
================

[](#features-alpha)

- JSX-like syntax
- component composition
- named slots
- AST compiler
- minimal runtime
- integration tests

---

Installation
============

[](#installation)

```
composer require pcp/pcp:@alpha
```

---

Basic setup
===========

[](#basic-setup)

```
$config = PCPConfig::defaults();
$config->roots = ['components'];
$config->cacheDir = 'cache';

$pcp = new PCP($config);
$pcp->registerAutoload();
```

Now components are compiled automatically when used.

---

Syntax overview
===============

[](#syntax-overview)

### Elements

[](#elements)

```

    Hello

```

### Expressions

[](#expressions)

```
{ $name }

```

### Components

[](#components)

```

```

### Fragments

[](#fragments)

```

    Title
    Text

```

---

Project structure
=================

[](#project-structure)

Recommended layout:

```
components/
  App/
    Components/
      Card.pcp
      Page.pcp

```

---

Development
===========

[](#development)

Run tests:

```
composer test
```

---

Roadmap
=======

[](#roadmap)

Planned features:

- better error messages
- ``
- `` self-closing support
- dev HMR improvements
- IDE tooling
- syntax highlighting

---

Inspiration
===========

[](#inspiration)

PCP takes inspiration from:

- React
- Astro
- JSX
- modern component compilers

But compiles to **pure PHP**.

---

License
=======

[](#license)

MIT

###  Health Score

37

—

LowBetter than 84% of packages

Maintenance98

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 71.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

12d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/aea056bff61e481cde437bfefe391afb32440224f4c9b34d04168f68c8522678?d=identicon)[StarDragonStudios](/maintainers/StarDragonStudios)

---

Top Contributors

[![RodrigoMurilloBannuelos](https://avatars.githubusercontent.com/u/152415372?v=4)](https://github.com/RodrigoMurilloBannuelos "RodrigoMurilloBannuelos (5 commits)")[![Dragonatte](https://avatars.githubusercontent.com/u/98835658?v=4)](https://github.com/Dragonatte "Dragonatte (2 commits)")

---

Tags

phpcomponentstemplateviewSSR

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/pcp-pcp/health.svg)

```
[![Health](https://phpackages.com/badges/pcp-pcp/health.svg)](https://phpackages.com/packages/pcp-pcp)
```

###  Alternatives

[eftec/bladeone

The standalone version Blade Template Engine from Laravel in a single php file

8288.1M71](/packages/eftec-bladeone)[eftec/bladeonehtml

The standalone version Blade Template Engine from Laravel in a single php file

1016.6k5](/packages/eftec-bladeonehtml)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
