Hi all,
In 2024, I have started porting a python library open tamil
https://github.com/Ezhil-Language-Foundation/open-tamil/.
I faced difficulties on tracking the port status of the application and noting the python symbols with php implementation with testing and documenting the changes over time because the code base itself not a small one.
so i have decided to prioritize tracking than the porting.
kick started the tracking with a mapping file and a php script fine tuned the process with explaining the difficulties
Step 1 :
i want a porting status tracker in php which reads the symbols in a python code and it require equivalent symbol with working status and documentation is it possible?
CHATGPT : Yes, it’s absolutely possible 
You can build a porting status tracker in PHP that analyzes Python code, extracts symbols (functions, classes, methods, variables), and then checks against a mapping of equivalent PHP symbols with their status (e.g., ported / not ported / partially working) and optional documentation.
Here’s how you can approach it:
High-Level Approach
- Parse Python code
- Extract symbols like
def function_name,class ClassName, global variables, and imports. - You can do this with regex (simpler) or by calling Python’s
astmodule and returning JSON for PHP to read.
- Extract symbols like
- Maintain a Mapping Table
- A JSON or database table that maps:
python_symbol→php_equivalent,status,notes
{ "print": { "php_equivalent": "echo", "status": "ported", "notes": "Direct replacement" }, "len": { "php_equivalent": "count", "status": "ported", "notes": "Works on arrays" }, "dict": { "php_equivalent": "associative array", "status": "in-progress", "notes": "Limited support" } } - A JSON or database table that maps:
- Tracker Logic
- For each symbol found in the Python code, check if it exists in the mapping.
- Output a report (HTML table / JSON / CLI output) with:
- Symbol name
- PHP equivalent
- Porting status
- Documentation/Notes
- Visualization
- You can show progress in percentage:
Total Symbols: 50 Ported: 30 (60%) Pending: 20 (40%)
- You can show progress in percentage:
Example PHP Implementation (Simple Version)
<?php
class PortingTracker {
private $mapping;
public function __construct($mappingFile) {
$this->mapping = json_decode(file_get_contents($mappingFile), true);
}
public function analyzePythonFile($pythonFile) {
$code = file_get_contents($pythonFile);
// Simple regex to find defs and classes
preg_match_all('/def\s+([a-zA-Z0-9_]+)/', $code, $functions);
preg_match_all('/class\s+([a-zA-Z0-9_]+)/', $code, $classes);
$symbols = array_merge($functions[1], $classes[1]);
$report = [];
foreach ($symbols as $symbol) {
if (isset($this->mapping[$symbol])) {
$report[$symbol] = $this->mapping[$symbol];
} else {
$report[$symbol] = [
"php_equivalent" => null,
"status" => "missing",
"notes" => "No mapping found"
];
}
}
return $report;
}
}
// Example usage
$tracker = new PortingTracker("mapping.json");
$result = $tracker->analyzePythonFile("example.py");
echo "<table border='1' cellpadding='5'>";
echo "<tr><th>Python Symbol</th><th>PHP Equivalent</th><th>Status</th><th>Notes</th></tr>";
foreach ($result as $py => $info) {
echo "<tr>
<td>{$py}</td>
<td>{$info['php_equivalent']}</td>
<td>{$info['status']}</td>
<td>{$info['notes']}</td>
</tr>";
}
echo "</table>";
Output Example (HTML Table)
| Python Symbol | PHP Equivalent | Status | Notes |
|---|---|---|---|
| echo | ported | Direct replacement | |
| len | count | ported | Works on arrays |
| dict | associative array | in-progress | Limited support |
| MyClass | NULL | missing | No mapping found |
Next-Level Features
- Use Python AST (
astmodule) to extract symbols more reliably instead of regex.
(You can runpython3 script.py example.py > symbols.jsonand then load that JSON in PHP.) - Add progress bar UI for tracking completion.
- Add search & filter for large projects.
- Store mapping in MySQL/Postgres for collaborative tracking.
Do you want me to make a standalone PHP tool (self-contained with regex parsing), or do you prefer a hybrid approach (use Python AST to export JSON, then PHP reads it)?
The hybrid one is much more reliable for real-world Python code.
This answer make me a decision on the porting of the python.
Started implementing the same but I have to satisfy the how ? inside me.