PHP to TypeScript
migration FAQ

Everything you need to know about migrating PHP to TypeScript with Pext. Can't find your answer?

Migrating to TypeScript

Yes. Pext migrates Laravel applications and the Illuminate components they use to TypeScript that runs on Node.js. Framework packages are tracked one by one on the roadmap, with their PHPUnit pass rates, so you can see how ready your exact stack is before you start.

Yes. Pext migrates your Composer dependencies along with your own code, and publishes each one as a TypeScript package your migrated app imports. The roadmap lists more than 800 PHP packages with their conversion and test status.

A rewrite re-implements behaviour by hand and has to rediscover every edge case. Pext migrates the code you already have, keeps PHP semantics through its runtime, and proves equivalence by running your existing PHPUnit suite against the TypeScript output. You keep shipping while the migration lands.

Pre-Migration

In most cases, no. There are a small number of syntax patterns where Pext cannot convert code directly; named arguments in function calls (PHP 8.0) are one example. Another is comment-based attributes (the @annotation docblock style used in pre-8.0 codebases and still prevalent in PHPUnit, Doctrine, and Symfony), which are rewritten into native #[Attribute] form so they can go through the regular attribute pipeline. For all these cases, Pext includes an automated pre-processing step that applies the necessary corrections before migration begins. No manual intervention is required.

There is no upper bound on project size. On the lower end, Pext is best suited to non-trivial projects, where the tooling and engagement model are designed for codebases that warrant a full migration effort.

Pext was designed to cover PHP 5.5 through 8.4. Most of the open source projects in our showcase use PHP 8.x, which represents the primary focus of our testing and validation. That said, no version in that range is intentionally excluded, though compatibility coverage across specific versions is still being characterised.

Ideally, no refactoring or restructuring of the codebase is needed before migrating. Pext converts file by file and faithfully reproduces the original file system structure in the output. Non-PHP resources are copied across automatically.

Dependencies are included in the migration: the entire vendor directory is converted to TypeScript alongside your own code. There is no implicit or special-cased vendor handling. Frameworks and libraries such as Laravel, PHPUnit, and Symfony are migrated as regular PHP code and become part of the TypeScript project output.

They are not. Code that is not written in native PHP (such as C extensions) is outside the scope of migration. After conversion, such extensions can be replaced with equivalent Node.js libraries or rewritten for the TypeScript ecosystem. We offer this as part of our consultancy engagement.

Post-Migration

Yes, that is the primary goal of Pext: delivering a TypeScript codebase that your team can continue building on. Readability of the output is a core focus, though functional correctness always takes precedence. The Pext team continuously works to simplify the generated code without putting correctness at risk.

Pext includes post-migration tooling that performs static analysis on the output, checking for syntax correctness, dead code, redundant code, and similar issues. That said, TypeScript types are erased at runtime, and static analysis alone cannot guarantee runtime correctness. The most reliable confirmation is a test suite: any existing PHP tests that can be run against the migrated output are highly valuable for verifying behavioural equivalence.

The migrated code relies on the Pext runtime to faithfully reproduce PHP behaviours, including a non-trivial set of quirks and edge cases that are handled transparently by the Pext layer. To run it, use the `pext` CLI: a pre-configured Node.js environment that embeds the Pext runtime and handles all necessary bootstrapping. The goal is for the `pext` CLI to be a complete replacement for the `php` CLI, so you can execute migrated code exactly as you did in the original project.

No. The goal of Pext is to produce a fully functional TypeScript project, with no manual intervention required. If any part of the output needed hand-editing to work correctly, that would indicate a bug in the migration engine, which we would fix on our end. The resulting code is intended to be complete and ready to deploy as-is.

All required third-party dependencies are bundled through the Pext layer (for example, libxml bindings for XML processing). You do not need to source or configure them separately. Pext takes responsibility for the safety and curation of every third-party package used in the converted output.

Run-time

Constructs with no direct TypeScript equivalent are routed through the Pext runtime, which provides the necessary implementations. For example, pass-by-reference is handled within the runtime: variables are wrapped in a Pext-specific type that carries the reference semantics PHP developers expect. Similarly, PHP arrays are reimplemented as a custom Pext type that replicates their full behaviour (ordered iteration, associative keys, automatic integer key generation, internal cursor, and so on). Where appropriate, plain TypeScript constructs are used directly to mirror the original PHP behaviour. The goal is that these constructs behave identically to their PHP counterparts without requiring any changes to the converted code.

Performance is important to the Pext team, but functional correctness always comes first. Pext is oriented towards full PHP compatibility under reasonable performance standards, and strives to be on par with PHP in most cases. That said, some PHP patterns may not map perfectly to the TypeScript runtime model; JIT compilation behaviour is one example where differences can emerge. Because the converted code is entirely yours, you have the freedom to identify and optimise hot spots using plain TypeScript, while leaving the bulk of non-critical code untouched.

The Pext runtime is split into 27+ independent npm modules, each covering a specific area of PHP's standard library: pext-core (scoping, value semantics, arrays), pext-strings, pext-arrays, pext-math, pext-pcre, pext-dom, pext-reflection, pext-json, pext-date-time, pext-file-handling, pext-iterators, and more. Each module is its own npm package with its own test suite. If your application never uses DOM, you never ship pext-dom. You can audit, replace, or vendor individual modules without touching the rest.

No. The runtime is a set of npm packages with no SaaS component, no cloud dependency, no license server in the hot path, and no phone-home. Your application runs anywhere Node runs: AWS, GCP, Azure, on-prem, air-gapped environments, your own hardware. Pext has zero opinions about where your application runs and zero presence in your production infrastructure. The one exception is eval: if your PHP code uses eval to execute dynamically generated PHP at runtime, that code is migrated on the fly via the Pext conversion API. For most codebases, we recommend rewriting eval usage to eliminate this dependency.

There is a well-defined scope for what can be carried over from PHP in terms of dynamic code execution. Pext will not run any PHP code at migration time or at runtime; the output is TypeScript only. If the migrated code generates PHP code dynamically, executing it must go through eval, which will convert it on the spot with certain limitations. I/O operations that reference .php file extensions (such as checking for file existence) are supported with limitations. The Pext runtime can be configured to resolve these automatically by rewriting .php paths to .js equivalents on the fly.

Infrastructure & Deploy

Currently, Pext provides a CLI equivalent to the PHP CLI. If the original application was served by Apache or NGINX using mod_php, routing those requests through the Pext CLI in place of the PHP CLI will yield the same result. Pext plans to expand on deployment in future, with more canonical deployment paths. In the meantime, how the resulting TypeScript code is deployed is your decision; the output is standard Node.js and can be run in any environment that supports it.

The Pext runtime currently targets Node.js 22. The generated code is intentionally vanilla: it runs natively on the V8 engine without requiring an additional build step, a compiler such as Babel, or experimental feature flags. The output is self-contained and ready to run as-is.

Yes. If the testing framework is part of the converted project, it is migrated alongside the application code. PHPUnit, for example, is fully supported: Pext has ported it to TypeScript, so your existing PHPUnit test suite runs against the migrated output from day one, without any rewriting or migration to Jest.

No. Pext converts code file by file, and each PHP file is migrated to its TypeScript equivalent independently, without requiring knowledge of the rest of the project. This means you can convert incrementally and ship files at your own pace.

Licensing & Pricing

Pricing is determined on a per-customer basis, depending on the services required: conversion, consultancy, maintenance, or a combination. Book a demo to discuss your needs and work out the right next steps.

The migration engine (pextc) is closed-source and proprietary. It is the core mechanism behind the PHP-to-TypeScript conversion. Its binaries are not distributed. The Pext team runs the migration engine in-house and delivers the converted output directly to you.

Any migration engagement is conducted under a prior agreement that establishes the appropriate disclosure boundaries. Our team is experienced with enterprise codebases and operates with the confidentiality standards that entails. The tooling runs entirely offline, and your code is never transmitted to external services.

The Pext runtime is distributed as binaries on a per-module basis, covering areas such as arrays, DOM, JSON, and so on. During the migration engagement, you are licensed to use the runtime for testing the converted application. Once the engagement concludes, you receive a perpetual licence to run the runtime in the context of your converted project. This licence also extends to new TypeScript code developed within the same company using the Pext runtime. It does not cover redistribution or resale of the runtime to third parties.

The converted code belongs to the owner of the original PHP codebase, as established in the agreement made prior to the engagement. Pext makes no claim over the business logic of the converted output. The licensing of the final TypeScript code, and the extent to which the Pext team may continue processing the shared source, is entirely at the discretion of the codebase owner.

At the close of a migration engagement, the owner receives a runtime licence for the latest major version available at that time. Under a maintenance agreement, this includes regular updates (minor versions) for a defined support window within that major version. Extended maintenance beyond the standard support period is available through a separate agreement. Upgrading to a new major version is not covered by the standard support obligations: major runtime versions correspond to specific conversion generations, and migrating to a new major requires adapting the converted code to the updated runtime. Code migration assistance for major version upgrades is not included implicitly; Pext offers consultancy services for this.

Ready to break free from PHP?

Book a personalized demo and see how Pext can transform your codebase from legacy PHP to modern TypeScript, without rewriting a single line by hand.