SlideShare ist ein Scribd-Unternehmen logo
1 von 24
PHP Internals
Nico Loubser
Developer at …..
“One night only” Curriculum.
Focus on concepts that will allow you to build things.
Lexical analysis
Syntax analysis [PHP7]
Opcode
Extensions
And some interesting facts about PHP
Terminology
1. Zvals are the datastructures holding PHP variable data. Variable points to a
Zval
2. A Reference !== Passing by reference. Reference === `Points`
3. Variables references zvals
4. Heap is the memory where zvals live
PHP Execution
Interpreted, compiled, or both?
These are the typical steps of a multipass compiler
- Lexical analysis
- Syntax analysis
- Some other steps maybe….
- Opcode [Final compilation]
Lexical analysis
Step one. Converts a script into tokens by Zend’s token engine. Really? Yes
really.
Lexical analysis. What does tokenized data look like?
Lexical analysis - can we use it for anything?
Source code highlighting and other tools.
Syntax analysis
PHP 7 introduced AST
More maintainable parser and compiler
Decoupling syntax decisions from technical issues
AST - parse tree for PHP script. [ https://github.com/nikic/PHP-Parser ]
AST - Generated code
AST - Generated code
Opcode
VLD / Bytekit / Parsekit
I used VLD, easiest to get to work.
Vulcan Logic Disassembler
Bytekit doesn’t seem to be supported, Parsekit results same is VLD.
Vulcan Logic Disassembler
ZVALS
How PHP represents data and keeps count of references for instance.
Represented by a C type called a Union.
PHP5
Zvals
The important difference between PHP 5 and PHP 7 : share the same Zval, regardless of by value or
reference.
Only once some kind of modification is performed the array will be separated.
Simulation of the copy-on-write behavior
Time to run some scripts…..
[Script can be found in github]
Extension
The hard way.
The PHP way.
The C++ way.
Extensions
I used the PHP-CPP skeleton framework. http://www.php-cpp.com/
You will need sudo apt-get install php5-dev
In Makefile
Assign your extension name to the NAME parameter, and then create a ini file with the same name.
Put this in the ini file
extension=quintillion.so
Make && make install
Run php -i | grep quintillion
/etc/php5/cli/conf.d/quintillion.ini
Comparison of normal vs extension
Live long and prosper
Internals is very interesting topic.
Knowledge about internals is good for memory, good for speed, data-structures, native implementations to interface with something.
nicoloubser@gmail.com
@Nico_Loubser

Weitere ähnliche Inhalte

Was ist angesagt?

Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 1)
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 1)Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 1)
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 1)Binary Studio
 
Using ANTLR on real example - convert "string combined" queries into paramete...
Using ANTLR on real example - convert "string combined" queries into paramete...Using ANTLR on real example - convert "string combined" queries into paramete...
Using ANTLR on real example - convert "string combined" queries into paramete...Alexey Diyan
 
From V8 to Modern Compilers
From V8 to Modern CompilersFrom V8 to Modern Compilers
From V8 to Modern CompilersMin-Yih Hsu
 
Static analysis for perl
Static analysis for perlStatic analysis for perl
Static analysis for perlmoznion
 
Taming the resource tiger
Taming the resource tigerTaming the resource tiger
Taming the resource tigerElizabeth Smith
 
Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416Chicago Hadoop Users Group
 
Introduction to Kotlin for Java developer
Introduction to Kotlin for Java developerIntroduction to Kotlin for Java developer
Introduction to Kotlin for Java developerShuhei Shogen
 
Raspberry using Python Session 1
Raspberry using Python Session 1Raspberry using Python Session 1
Raspberry using Python Session 1Mohamed Abd Ela'al
 
Rest style web services (google protocol buffers) prasad nirantar
Rest style web services (google protocol buffers)   prasad nirantarRest style web services (google protocol buffers)   prasad nirantar
Rest style web services (google protocol buffers) prasad nirantarIndicThreads
 
Py Con 2009 Pumping Iron Into Python
Py Con 2009   Pumping Iron Into PythonPy Con 2009   Pumping Iron Into Python
Py Con 2009 Pumping Iron Into PythonSarah Dutkiewicz
 
ANTLR4 and its testing
ANTLR4 and its testingANTLR4 and its testing
ANTLR4 and its testingKnoldus Inc.
 
1. introduction to php and variable
1. introduction to php and variable1. introduction to php and variable
1. introduction to php and variableNurAliaAqilaMuhalis
 
Presentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStackPresentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStackDavid Sanchez
 
Pharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban LorenzanoPharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban LorenzanoFAST
 

Was ist angesagt? (19)

Four Python Pains
Four Python PainsFour Python Pains
Four Python Pains
 
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 1)
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 1)Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 1)
Binary Studio Academy PRO: ANTLR course by Alexander Vasiltsov (lesson 1)
 
Kotlin from-scratch
Kotlin from-scratchKotlin from-scratch
Kotlin from-scratch
 
Using ANTLR on real example - convert "string combined" queries into paramete...
Using ANTLR on real example - convert "string combined" queries into paramete...Using ANTLR on real example - convert "string combined" queries into paramete...
Using ANTLR on real example - convert "string combined" queries into paramete...
 
From V8 to Modern Compilers
From V8 to Modern CompilersFrom V8 to Modern Compilers
From V8 to Modern Compilers
 
Static analysis for perl
Static analysis for perlStatic analysis for perl
Static analysis for perl
 
Taming the resource tiger
Taming the resource tigerTaming the resource tiger
Taming the resource tiger
 
eZ Publish 5 in depth inspection
eZ Publish 5 in depth inspectioneZ Publish 5 in depth inspection
eZ Publish 5 in depth inspection
 
Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416
 
Php
PhpPhp
Php
 
Introduction to Kotlin for Java developer
Introduction to Kotlin for Java developerIntroduction to Kotlin for Java developer
Introduction to Kotlin for Java developer
 
Raspberry using Python Session 1
Raspberry using Python Session 1Raspberry using Python Session 1
Raspberry using Python Session 1
 
Rest style web services (google protocol buffers) prasad nirantar
Rest style web services (google protocol buffers)   prasad nirantarRest style web services (google protocol buffers)   prasad nirantar
Rest style web services (google protocol buffers) prasad nirantar
 
Py Con 2009 Pumping Iron Into Python
Py Con 2009   Pumping Iron Into PythonPy Con 2009   Pumping Iron Into Python
Py Con 2009 Pumping Iron Into Python
 
Null
NullNull
Null
 
ANTLR4 and its testing
ANTLR4 and its testingANTLR4 and its testing
ANTLR4 and its testing
 
1. introduction to php and variable
1. introduction to php and variable1. introduction to php and variable
1. introduction to php and variable
 
Presentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStackPresentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStack
 
Pharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban LorenzanoPharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban Lorenzano
 

Andere mochten auch

Php 7.x 8.0 and hhvm and
Php 7.x 8.0 and hhvm and Php 7.x 8.0 and hhvm and
Php 7.x 8.0 and hhvm and Pierre Joye
 
Extending php (7), the basics
Extending php (7), the basicsExtending php (7), the basics
Extending php (7), the basicsPierre Joye
 
Php On Windows Internals
Php On Windows InternalsPhp On Windows Internals
Php On Windows InternalsPierre Joye
 
Phpcompilerinternals 090824022750-phpapp02
Phpcompilerinternals 090824022750-phpapp02Phpcompilerinternals 090824022750-phpapp02
Phpcompilerinternals 090824022750-phpapp02philipo
 
Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure
Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure
Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure National Cheng Kung University
 
PHP, Under The Hood - DPC
PHP, Under The Hood - DPCPHP, Under The Hood - DPC
PHP, Under The Hood - DPCAnthony Ferrara
 
The Php Life Cycle
The Php Life CycleThe Php Life Cycle
The Php Life CycleXinchen Hui
 
Php Extensions for Dummies
Php Extensions for DummiesPhp Extensions for Dummies
Php Extensions for DummiesElizabeth Smith
 
How PHP Works ?
How PHP Works ?How PHP Works ?
How PHP Works ?Ravi Raj
 
Understanding PHP memory
Understanding PHP memoryUnderstanding PHP memory
Understanding PHP memoryjulien pauli
 
About Tokens and Lexemes
About Tokens and LexemesAbout Tokens and Lexemes
About Tokens and LexemesBen Scholzen
 

Andere mochten auch (15)

Php 7.x 8.0 and hhvm and
Php 7.x 8.0 and hhvm and Php 7.x 8.0 and hhvm and
Php 7.x 8.0 and hhvm and
 
Extending php (7), the basics
Extending php (7), the basicsExtending php (7), the basics
Extending php (7), the basics
 
Php On Windows Internals
Php On Windows InternalsPhp On Windows Internals
Php On Windows Internals
 
Phpcompilerinternals 090824022750-phpapp02
Phpcompilerinternals 090824022750-phpapp02Phpcompilerinternals 090824022750-phpapp02
Phpcompilerinternals 090824022750-phpapp02
 
How PHP works
How PHP works How PHP works
How PHP works
 
Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure
Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure
Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure
 
Build Programming Language Runtime with LLVM
Build Programming Language Runtime with LLVMBuild Programming Language Runtime with LLVM
Build Programming Language Runtime with LLVM
 
PHP, Under The Hood - DPC
PHP, Under The Hood - DPCPHP, Under The Hood - DPC
PHP, Under The Hood - DPC
 
The Php Life Cycle
The Php Life CycleThe Php Life Cycle
The Php Life Cycle
 
Php Extensions for Dummies
Php Extensions for DummiesPhp Extensions for Dummies
Php Extensions for Dummies
 
PHP 7 new engine
PHP 7 new enginePHP 7 new engine
PHP 7 new engine
 
How PHP Works ?
How PHP Works ?How PHP Works ?
How PHP Works ?
 
Understanding PHP memory
Understanding PHP memoryUnderstanding PHP memory
Understanding PHP memory
 
About Tokens and Lexemes
About Tokens and LexemesAbout Tokens and Lexemes
About Tokens and Lexemes
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 

Ähnlich wie PHP Internals

Listen and look at your PHP code
Listen and look at your PHP codeListen and look at your PHP code
Listen and look at your PHP codeGabriele Santini
 
chapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdfchapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdfburasyacob012
 
Php extensions workshop
Php extensions workshopPhp extensions workshop
Php extensions workshopjulien pauli
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPtutorialsruby
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPtutorialsruby
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPrinceGuru MS
 
How Symfony Changed My Life
How Symfony Changed My LifeHow Symfony Changed My Life
How Symfony Changed My LifeMatthias Noback
 
Unleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformUnleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformSébastien Morel
 
Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHPEric Johnson
 
<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />tutorialsruby
 
<b>PHP</b> Reference: Beginner to Intermediate <b>PHP5</b>
<b>PHP</b> Reference: Beginner to Intermediate <b>PHP5</b><b>PHP</b> Reference: Beginner to Intermediate <b>PHP5</b>
<b>PHP</b> Reference: Beginner to Intermediate <b>PHP5</b>tutorialsruby
 

Ähnlich wie PHP Internals (20)

Listen and look at your PHP code
Listen and look at your PHP codeListen and look at your PHP code
Listen and look at your PHP code
 
chapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdfchapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdf
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Php introduction
Php introductionPhp introduction
Php introduction
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
Introduction to-php
Introduction to-phpIntroduction to-php
Introduction to-php
 
Php extensions workshop
Php extensions workshopPhp extensions workshop
Php extensions workshop
 
PHP ITCS 323
PHP ITCS 323PHP ITCS 323
PHP ITCS 323
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
 
Php&yii2
Php&yii2Php&yii2
Php&yii2
 
Php7
Php7Php7
Php7
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_master
 
How Symfony Changed My Life
How Symfony Changed My LifeHow Symfony Changed My Life
How Symfony Changed My Life
 
Unleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformUnleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ Platform
 
Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHP
 
Flyr PHP micro-framework
Flyr PHP micro-frameworkFlyr PHP micro-framework
Flyr PHP micro-framework
 
Guidelines php 8 gig
Guidelines php 8 gigGuidelines php 8 gig
Guidelines php 8 gig
 
<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />
 
<b>PHP</b> Reference: Beginner to Intermediate <b>PHP5</b>
<b>PHP</b> Reference: Beginner to Intermediate <b>PHP5</b><b>PHP</b> Reference: Beginner to Intermediate <b>PHP5</b>
<b>PHP</b> Reference: Beginner to Intermediate <b>PHP5</b>
 

PHP Internals

  • 2.
  • 3. “One night only” Curriculum. Focus on concepts that will allow you to build things. Lexical analysis Syntax analysis [PHP7] Opcode Extensions And some interesting facts about PHP
  • 4. Terminology 1. Zvals are the datastructures holding PHP variable data. Variable points to a Zval 2. A Reference !== Passing by reference. Reference === `Points` 3. Variables references zvals 4. Heap is the memory where zvals live
  • 5. PHP Execution Interpreted, compiled, or both? These are the typical steps of a multipass compiler - Lexical analysis - Syntax analysis - Some other steps maybe…. - Opcode [Final compilation]
  • 6. Lexical analysis Step one. Converts a script into tokens by Zend’s token engine. Really? Yes really.
  • 7. Lexical analysis. What does tokenized data look like?
  • 8. Lexical analysis - can we use it for anything? Source code highlighting and other tools.
  • 9. Syntax analysis PHP 7 introduced AST More maintainable parser and compiler Decoupling syntax decisions from technical issues AST - parse tree for PHP script. [ https://github.com/nikic/PHP-Parser ]
  • 12.
  • 13.
  • 14. Opcode VLD / Bytekit / Parsekit I used VLD, easiest to get to work. Vulcan Logic Disassembler Bytekit doesn’t seem to be supported, Parsekit results same is VLD.
  • 16.
  • 17. ZVALS How PHP represents data and keeps count of references for instance. Represented by a C type called a Union. PHP5
  • 18. Zvals The important difference between PHP 5 and PHP 7 : share the same Zval, regardless of by value or reference. Only once some kind of modification is performed the array will be separated.
  • 19.
  • 20. Simulation of the copy-on-write behavior Time to run some scripts….. [Script can be found in github]
  • 21. Extension The hard way. The PHP way. The C++ way.
  • 22. Extensions I used the PHP-CPP skeleton framework. http://www.php-cpp.com/ You will need sudo apt-get install php5-dev In Makefile Assign your extension name to the NAME parameter, and then create a ini file with the same name. Put this in the ini file extension=quintillion.so Make && make install Run php -i | grep quintillion /etc/php5/cli/conf.d/quintillion.ini
  • 23. Comparison of normal vs extension
  • 24. Live long and prosper Internals is very interesting topic. Knowledge about internals is good for memory, good for speed, data-structures, native implementations to interface with something. nicoloubser@gmail.com @Nico_Loubser

Hinweis der Redaktion

  1. My name is Nico and I am a PHP backend developer at...
  2. Payfast - Where every 2nd Friday, they stop the free head massages, they lock the beer fridge, they take away our kittens, but they allow us to work on a project of our own liking(This is the best of the three). So over the course of a few own fridays, and some evenings, I have studied PHP internals quite a bit and decided to share with you what I have learned. I am by no means an expert, and the questions I cannot answer now, I will answer in the Meetup group.
  3. I had to decide what topics I will talk about. I figured the best topics will be ones with a more tangible integration possibilities, so I decided I Will focus on concepts that you can use to build tools with, and may mix PHP 5 and 7, but I will make it clear when doing so. I will also cover some memory aspects of PHP.
  4. Most of us think of PHP as an interpreted language. PHP hasn’t been purely interpreted since PHP3. PHP 4 introduced the the Zend engine. Precompiles your syntax and produces opcode. [ It is still interpreted but Interpretation does not replace compilation completely, it only hides it from the user. ] This engine splits the processing of PHP code into several phases. This is part of any compilation process. These are the typical steps of a multipass compiler Lex analysis Syntax analysis opcode PHP gets compiled and as all compilers does, it changes syntax into a target format, and in this case a format that can be interpreted. OPcode caching causes PHP to skip the lexical and syntax steps as well in subsequent compilations. No need for APC and similar caching mechanisms as of PHP 5.5 and later. The PHP developers directly integrated what they call OPCache into the core of the product. Not only does this provide greater overall product stability, it is officially supported by the PHP developers.
  5. The very first step is a lexical analysis. We can use the exact same function that the ZEND engine uses to do the lexical analysis, using token_get_all and token name. token_get_all is declared as a PHP function giving us entry into the system. In orange you can see it calls the built in tokenize function. ON the right is the tokenize function, and in orange you can see it uses the lex_cscan method. Token_name function is then used to map the token numbers to their symbolic name.
  6. Tokenisation can generate a lot of data, so I am keeping my examples short. On the left hand side I am displaying the lexical analysis for a one liner. $number = 10 + 10; In the first column you can see the token id. This token is is returned from the function token_get_all, and we have to use token_name to get the symbolic names, which is displayed in the second columns. The 3rd column is the bit of syntax that was analysed and the line is the line number in the script. On the right hand side we have the exact same line, but commented out. As you can see the lexer stopped and didn’t analyse anything further, but even comments have a lexical tag
  7. In the following snippet I am importing a piece of code into token_get_all. Token get all returns the token ids. Not shown here is my css classes linked to a token id. By iterating through my returned array and applying the CSS classes, I managed to make a very promotive source code high lighter. What does the
  8. PHP7 introduced AST. RFC written by Nikita Popov, whos name features a lot with PHP internals Abstract syntax tree - More maintainable parser and compiler Decoupling syntax decisions from technical issues In this step the tokens are analysed for grammatical correctness, and allows static analysis of the code. Allows dealing with code in an abstract and robust way, and can be created for tools to view correctness of code. As far as I know there isn’t a build in tool we can use for this, so I used a tool called PHP-Parser to create the Syntax tree for me. What is really cool about AST’s are that you can generate normal syntax code from AST’s. You can traverse and edit the AST, ans then change it back into normal syntax. you can infact write code that changes itself, should you so desire. But one of the uses for this has been preparing code for porting to older systems, under what I assume could have been a much better rewrite of code, since mass find replaces aren’t possible.
  9. This is the tree that the previous code snippet generates
  10. One kind of problem one can solve using the above two techniques is the missing brackets problem. If anyone has ever worked in a structured block of code or even function of lets say a 1000 lines(yes they exist although they shouldnt) you may have stumbled across the issue of a missing bracket. You do a count for left braces and you get 301, then you do a count for right braces and you get 300. The rest of your day is basically gone. So I believe that the previous two techniques can be used to solve that problem and it is something I am thinking about working on.
  11. Opcode is generated based on the correctness of the previous two steps. There are numerous tools available, I decided to use VLD, as I couldn’t install Bytekit. COmparing PArsekit and Bytekit examples on the internet they both look very similar. YOu can learn a lot about the code by looking at the opcode.
  12. UNderstanding the behaviour of ZVALS us very important and especially in PHP 5 can make a difference in your code. Zvals are allocated on the HEAP, and referenced by PHP variables. Each ZVAL has a counter that counts the amount of references to it. It also has an is_Ref field which tells us whether something has been passed by reference to it. PHP uses copy on write when assigning and editing variables and I Will show that to you in a second
  13. IN PHP 7 zvals are not each independantly allocated on the heap, but stored in a hashmap. The hashmap however is still in the HEAP. Non complex types like int and long are no longer stored in the ZEND union but directly in the ZVAL. This way there are less pointers and lookups and things that you get in PHP 5.
  14. In PHP7 if you do a $a = 1; debug_zval_dump($a) you only see long(1), and not
  15. In PHP data is passed by reference, but references
  16. There are a few options available to create your own extensions THe hard way. Most probably done in C. This is hard for good reason and I will not go into it now, but I will say that you basically do everything yourself. The PHP way. There are PHP based libraries that simplifies this task for you. A very good website exists for it, but I cannot find it again. The C++ way is the way I decided to go.
  17. I used the PHP-CPP skeleton framework and of course php5-dev. The skeleton provides everyting you need. The correct folders, config files. Make and make install has placed it in the correct directories for me.
  18. PHP does not really distinguish a number type and a string type. This behavior complies to the PHP standard. Also due to this behavior, we didn’t and can’t use C++ internal types for the temporary variable used in the function (temp) but used Php::Value as the variable type. Using int and string is internal only