---
title: "Two-step creation for PHP modules"
url: https://daily.dev/posts/two-step-creation-for-php-modules-ljafcvfrf
source_url: https://externals.io/message/131215
type: article
source: "externals.io"
published: 2026-06-12T17:12:07.426Z
updated: 2026-06-12T17:12:33.231Z
tags: ["general-programming", "php"]
reading_time: 68
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)** · 68 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)` — files with zero global side effects, containing only declarations (classes, functions, constants, etc.) and no executable statements. Step two builds on this foundation to create 'PHP modules' declared with `declare(module=1)`, which gain `import` and `export` keywords for explicit, scoped dependency management. Internally, module symbols would be hash-prefixed to prevent namespace collisions, enabling tree-shaking of unused exports. The proposal also covers Composer integration via a new `spl_register_module()` function and `composer.json` fields. A proof-of-concept PR for definition files has already been submitted to php-src. A reply from Rowan Tommins raises concerns that the design mirrors JavaScript's module system too closely and may not fit 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/131215>

## Similar posts on daily.dev

- [Two-step creation for PHP modules](https://daily.dev/posts/two-step-creation-for-php-modules-8o6vgn4zv) · externals.io · 0 upvotes · 0 comments
- [Two-step creation for PHP modules](https://daily.dev/posts/two-step-creation-for-php-modules-ka7imxr1b) · externals.io · 0 upvotes · 0 comments
- [Two-step creation for PHP modules](https://daily.dev/posts/two-step-creation-for-php-modules-4xkzm3qco) · externals.io · 0 upvotes · 0 comments
- [Two-step creation for PHP modules](https://daily.dev/posts/two-step-creation-for-php-modules-xyvwn1fjv) · externals.io · 0 upvotes · 0 comments
- [Two-step creation for PHP modules](https://daily.dev/posts/two-step-creation-for-php-modules-1ltrewsrl) · 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-ljafcvfrf)
