✨ A lightweight, smart DSL (Domain-Specific Language) that compiles
.ephpfiles into modern, readable PHP — helping you write PHP faster, cleaner, and more pythonic 🐍➡️🐘
This is a simple DSL that allows you to write .ephp files (inspired by Python syntax) and convert them to standard PHP code.
Yes! You can write Python-style code that becomes valid PHP!
No need to worry about {} or $ or even boilerplate functions. Just focus on logic — this tool handles the transformation.
-
funckeyword for PHP functions (with type hints and default values) -
with ... as ...:context blocks (auto fclose on file handles) -
match ...:expressions withcase,default, assignment orreturn -
do:andwhile ...structure -
for x in range(...)andfor x in collection:loops - Inline ternary expressions
- Anonymous functions:
x = fn(...) => ...and multiline ones too - Python-like expressions (
a and b,not,True,len(x)→count($x), etc.) - F-Strings:
f"Hello {name}!"→"Hello " . $name . "!" - Auto
$handling - Constants with
UPPER_CASE = value - Native PHP support inside
.ephpfiles - Readable, pretty formatted PHP output
- IntelliSense / language extension for VS Code
- Syntax highlighting
- Better error handling and CLI feedback
-
class/ OOP support (currently not planned) - Support for
try-exceptblocks - More advanced list and dict operations
import "utils.ephp"
func greet(name = "World") str:
return f"Hello, {name}!"
name = input("Enter your name:")
print(greet(name))<?php
// Generated by DSL to PHP converter
require_once "utils.php";
function greet(string $name = "World"): string {
return "Hello, " . $name . "!";
}
$name = readline("Enter your name:");
echo greet($name);x = 10
name = input("Your name:")
greeting = f"Hi, {name}"➡️
$x = 10;
$name = readline("Your name:");
$greeting = "Hi, " . $name;for i in range(5):
print(i)
if x > 5:
print("Big")
else:
print("Small")➡️
for ($i = 0; $i < 5; $i += 1) {
echo $i;
}
if ($x > 5) {
echo "Big";
} else {
echo "Small";
}result = match x:
case 1: "One"
case 2 or 3: "Two or Three"
default: "Other"➡️
$result = match ($x) {
1 => "One",
2, 3 => "Two or Three",
default => "Other",
};This entire project — including this README — was built with the help of ChatGPT and DeepSeek AI 🤖
We used AI assistance to prototype, refine, and ship this converter faster.
This DSL is meant to simplify PHP development and boost productivity. However, it’s still a work in progress.
If you’re a PHP developer or just love compilers / syntax tools, we’d love your help!
- Help build a minimal, powerful PHP DSL
- Learn about DSLs, code parsing, AST-like transforms
- Make PHP more fun and friendly
PRs are welcome. Bug reports too. Let’s make PHP great again 😄
- You can directly use any native PHP functions in
.ephpfiles. - It won’t touch those lines — they'll be passed as-is.
- Currently, IntelliSense and syntax highlighting in editors like VSCode are not available.
- You can help by building a VSCode extension for
.ephp
- You can help by building a VSCode extension for
python php_dsl.py file.ephp
# OR
python php_dsl.py file.ephp output.phpMIT — free to use, modify, or extend.
Star the repo if you like it. Fork it, play with it, improve it! 😎
Use .ephp to prototype your PHP logic faster. Once ready, convert it to .php and deploy with confidence!