Hi all,
I would like to learn more about how the interpreter works, but I was
unable to find good documents on the web. Basically I am thinking on
something about allocation of variables, how does object creation work
and such stuff. Maybe something on the overall architecture of PHP
would be of interest too.
In java world there is the JVM specification, I hoped there is
something for PHP too.
Best regards and thanks for all help,
Christian
Christian Grobmeier grobmeier@gmail.com wrote on 21/12/2009 13:56:08:
I would like to learn more about how the interpreter works, but I was
unable to find good documents on the web. Basically I am thinking on
something about allocation of variables, how does object creation work
and such stuff. Maybe something on the overall architecture of PHP
would be of interest too.In java world there is the JVM specification, I hoped there is
something for PHP too.
Hi Christian,
The PHP architecture is a little different from the JVM in that it does not
explicitly document/specify the interface between the compiler and the
bytecode/opcode interpreter the way that Java does. It still exists though.
I suggest you look at the links under here:
http://www.php.net/manual/en/internals2.php
In particular:
http://www.php.net/manual/en/internals2.opcodes.php
Another good reference is Sara Goleman's book "Extending and Embedding PHP"
Andy Wharmby produced a set of charts which you can find on Zoe's Blog
here : http://zoomsplatter.blogspot.com/2008/08/php-opcodes.html .
These may help you to make a fast start understanding the overall design.
Rob.
Hello,
this document is clearly outdated and for me so far confuse just gave
a try for 5 mins, and I am worry about the printf tech, lucky you are
not to be in multi-thread env..., at least fprintf on the stderr to
read un-buffered results, those guys have a job? maybe greenhouse
keepers certainly not developers.
Christian, the best way to enter in the zend engine, it's to create a
zend extension project, then go thru all the step of the code to
manipulate the hashtable, learn where object are living in the tree,
then when you know how to play with the "public" interface, that's
really easy to go deeper, the zend "bytecode engine" is so far less
complex that what you could find in any JVM (I know a couple of things
in area) even python bytecode and how the interpreter is able to
handle various version,
in two weeks you should have done your tour by using the zend
interface and reading the code, php zend core is tiny in term of code,
the only things that could appear weird and clumsy is the semantic
code used, this is the only thing that could appear like a mind
barrier.
Best,
Christian Grobmeier grobmeier@gmail.com wrote on 21/12/2009 13:56:08:
I would like to learn more about how the interpreter works, but I was
unable to find good documents on the web. Basically I am thinking on
something about allocation of variables, how does object creation work
and such stuff. Maybe something on the overall architecture of PHP
would be of interest too.In java world there is the JVM specification, I hoped there is
something for PHP too.Hi Christian,
The PHP architecture is a little different from the JVM in that it does not
explicitly document/specify the interface between the compiler and the
bytecode/opcode interpreter the way that Java does. It still exists though.I suggest you look at the links under here:
http://www.php.net/manual/en/internals2.php
In particular:
http://www.php.net/manual/en/internals2.opcodes.phpAnother good reference is Sara Goleman's book "Extending and Embedding PHP"
Andy Wharmby produced a set of charts which you can find on Zoe's Blog
here : http://zoomsplatter.blogspot.com/2008/08/php-opcodes.html .
These may help you to make a fast start understanding the overall design.Rob.
Hi,
Rob Nicholson wrote:
Another good reference is Sara Goleman's book "Extending and Embedding PHP"
actually this is what i was searching for. I will order this book now.
Thanks for the tipp!
Christian
Hi,
I would like to learn more about how the interpreter works, but I was
unable to find good documents on the web. Basically I am thinking on
something about allocation of variables, how does object creation work
and such stuff. Maybe something on the overall architecture of PHP
would be of interest too.In java world there is the JVM specification, I hoped there is
something for PHP too.
Well there's one quite complete document about it available - the source
code ;-) PHP isn't developed following standards but simply by
implementing and extending it. PHP is defined by the implementation ...
But: What exactly do you want to learn? Do you want to learn how to use
it better or "academic reasons" or something else? - Depending on all
that the focus of the learning might be quite different.
As a starting point for this I recently created a small toy project: A
minimal basic inspired language on top of the ZendVM, just 200 lines of
C code which might give a few pointers to do further research. It's
quite hackish ugly code but enough to compile and execute a script like
this:
10 GOTO 40
20 PRINT "B"
30 END
40 PRINT "A"
50 GOTO 20
This all will be compiled to Zend Opcodes which can be executed, cached
with APC, dumped by vld, ...
I hope I find the time to write the documentation around it, other than
that this code is absolutely useless :-)
http://github.com/johannes/pasic
johannes
Pas mieux, and I am sure johannes did not find the need to express
himself and/or these mind limitations on his blog :)
harf I am so bad I know.
-mmw
2009/12/21 Johannes Schlüter johannes@php.net:
Hi,
I would like to learn more about how the interpreter works, but I was
unable to find good documents on the web. Basically I am thinking on
something about allocation of variables, how does object creation work
and such stuff. Maybe something on the overall architecture of PHP
would be of interest too.In java world there is the JVM specification, I hoped there is
something for PHP too.Well there's one quite complete document about it available - the source
code ;-) PHP isn't developed following standards but simply by
implementing and extending it. PHP is defined by the implementation ...But: What exactly do you want to learn? Do you want to learn how to use
it better or "academic reasons" or something else? - Depending on all
that the focus of the learning might be quite different.As a starting point for this I recently created a small toy project: A
minimal basic inspired language on top of the ZendVM, just 200 lines of
C code which might give a few pointers to do further research. It's
quite hackish ugly code but enough to compile and execute a script like
this:10 GOTO 40
20 PRINT "B"
30 END
40 PRINT "A"
50 GOTO 20This all will be compiled to Zend Opcodes which can be executed, cached
with APC, dumped by vld, ...I hope I find the time to write the documentation around it, other than
that this code is absolutely useless :-)http://github.com/johannes/pasic
johannes