I was interested in adding some feature to the php syntax, and definitly it's obvious for me it's different from writing modules for the language. I was wondering this requires to edit the resource in C which is avaialble on the php.net website and naturally C programming knowledge. Simply I want do the below:
xforeach ($array as $item with $counter) {
echo "This is $counter time this loop is happening";
}
Rather than writing:
$counter = 0;
foreach ($array as $item) {
echo "This is $counter time this loop is happening";
$counter ++;
}
or in another glimpse, adding attribute to each class or function, like it's possible in C#
class MyClass {
[Description("This is my php 6 version")]
public function Test() {
}
}
What is the first step on the way to achieving this approach?
See how other people did it: http://hacklang.org/ (from facebook)
They build their own language on php (which compiles to php in the end)
What you do is:
Note: this is also how template engines work, like Twig.
In the end you either write php or you write C#.
Note: Even if you would succeed their would not be an IDE with IntelliSense to write your code in.
why would you want to make php like C#, why not just code in C#?
Note: vNext (MVC6) will be able to run on Linux servers as well, with the new Roslyn compiler.