PHPackages                             xp-lang/xp-static - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. xp-lang/xp-static

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

xp-lang/xp-static
=================

XP static initializer blocks

v2.0.0(2y ago)11.2kBSD-3-ClausePHPPHP &gt;=7.4.0

Since Dec 19Pushed 1y ago2 watchersCompare

[ Source](https://github.com/xp-lang/xp-static)[ Packagist](https://packagist.org/packages/xp-lang/xp-static)[ Docs](http://xp-framework.net/)[ RSS](/packages/xp-lang-xp-static/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (3)Versions (6)Used By (0)

XP static initializer blocks
============================

[](#xp-static-initializer-blocks)

[![Build status on GitHub](https://github.com/xp-lang/xp-static/workflows/Tests/badge.svg)](https://github.com/xp-lang/xp-static/actions)[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)[![Requires PHP 7.4+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_4plus.svg)](http://php.net/)[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)[![Latest Stable Version](https://camo.githubusercontent.com/e8578ad9ec5f447d81d9ad76da910d91e56f2f876c637c6c1e330a17c6a2a7a6/68747470733a2f2f706f7365722e707567782e6f72672f78702d6c616e672f78702d7374617469632f76657273696f6e2e737667)](https://packagist.org/packages/xp-lang/xp-static)

Plugin for the [XP Compiler](https://github.com/xp-framework/compiler/) which adds a static initializer syntax for PHP. This is compiled to `__static()` functions recognized by the XP class loading mechanism.

Example
-------

[](#example)

```
namespace com\example\brotli;

class Streams {
  static {
    stream_wrapper_register('brotli', self::class);
  }

  // ...
}
```

Installation
------------

[](#installation)

After installing the XP Compiler into your project, also include this plugin.

```
$ composer require xp-framework/compiler
# ...

$ composer require xp-lang/xp-static
# ...
```

No further action is required.

See also
--------

[](#see-also)

- [PHP RFC: Static Constructors](https://wiki.php.net/rfc/static_constructor) - 2024
- [PHP RFC: Static Class Constructor](https://wiki.php.net/rfc/static_class_constructor) - 2015
- [Class static initialization block @ PHP Internals (2021)](https://externals.io/message/116031)
- [Class static initialization blocks @ V8.dev](https://v8.dev/features/class-static-initializer-blocks)
- [Static constructor @ PHP Internals (2015)](https://externals.io/message/84602)
- [Static Constructors (C# Programming Guide)](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/static-constructors)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Every ~206 days

Total

5

Last Release

785d ago

Major Versions

v0.3.0 → v1.0.02023-05-27

v1.0.0 → v2.0.02024-03-24

PHP version history (2 changes)v0.1.0PHP &gt;=7.0.0

v2.0.0PHP &gt;=7.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/07d18d882c8b4aaf3466432f64018214f2771eda333202175431ee7233795376?d=identicon)[thekid](/maintainers/thekid)

---

Top Contributors

[![thekid](https://avatars.githubusercontent.com/u/696742?v=4)](https://github.com/thekid "thekid (21 commits)")

---

Tags

initializerphp7php8xp-compilerlanguagemodulexp

### Embed Badge

![Health badge](/badges/xp-lang-xp-static/health.svg)

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

PHPackages © 2026

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