---
title: "Two-step creation for PHP modules"
url: https://daily.dev/posts/two-step-creation-for-php-modules-fghcc1s8x
source_url: https://externals.io/message/131227
type: article
source: "externals.io"
published: 2026-06-13T15:59:01.224Z
updated: 2026-06-13T15:59:31.294Z
tags: ["general-programming", "php"]
reading_time: 83
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Two-step creation for PHP modules

**[externals.io](https://daily.dev/sources/externals)** · 83 min read · 0 upvotes · 0 comments

## Summary

A PHP internals mailing list proposal by Alex Rock outlines a two-step approach to adding a native module system to PHP. Step one introduces 'definition files' declared with `declare(def=1)` that have zero global state, no side-effects at runtime, and only contain declarations — making them safe for opcache and compile-time analysis. Step two builds on this foundation to create 'PHP modules' declared with `declare(module=1)`, adding `import` and `export` keywords with file-scoped encapsulation, hash-prefixed internal symbols, tree-shaking of unused exports, and Composer integration via a new `spl_register_module()` function. A proof-of-concept PR for definition files already exists. A reply from Rowan Tommins raises concerns that the proposal mirrors JavaScript's module system too closely rather than fitting PHP's Java/C#-like identity.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://externals.io/message/131227>

## Similar posts on daily.dev

- [Two-step creation for PHP modules](https://daily.dev/posts/two-step-creation-for-php-modules-vjjflyqqv) · externals.io · 0 upvotes · 0 comments
- [Two-step creation for PHP modules](https://daily.dev/posts/two-step-creation-for-php-modules-bvwsau12r) · externals.io · 0 upvotes · 0 comments
- [Two-step creation for PHP modules](https://daily.dev/posts/two-step-creation-for-php-modules-oo11taktc) · externals.io · 0 upvotes · 0 comments
- [Two-step creation for PHP modules](https://daily.dev/posts/two-step-creation-for-php-modules-iqpcncupn) · externals.io · 0 upvotes · 0 comments
- [Two-step creation for PHP modules](https://daily.dev/posts/two-step-creation-for-php-modules-sf3knezcu) · externals.io · 0 upvotes · 0 comments

---

Tags: [#general-programming](https://daily.dev/tags/general-programming), [#php](https://daily.dev/tags/php)

[View this post on daily.dev](https://daily.dev/posts/two-step-creation-for-php-modules-fghcc1s8x)
