Search code examples
phpapacheopcodephp-opcode

PHP vld shows file output instead of opcode


I'm trying to use vld to view opcode of a php file

prep

I've installed vld with:

pecl install channel://pecl.php.net/vld-0.12.0

To get familiar with VLD, I'm trying to compare to php files (echo1 and echo2)

echo1.php

<?php
echo "Hello"." "."World";

echo2.php

<?php
echo "Hello"," ","World";

phpinfo() shows that vld seems to be enabled:

vld support        enabled

Directive   Local Value Master Value
vld.active         0    0
vld.col_sep             
vld.dump_paths     1    1
vld.execute        1    1
vld.format         0    0
vld.save_dir       /tmp /tmp
vld.save_paths     0    0
vld.skip_append    0    0
vld.skip_prepend   0    0
vld.verbosity      1    1

problem

running php files shows output instead of opcode

# php -dvld.active=1 -f echo1.php
Hello World

# php -dvld.active=1 -dvld.execute=0 -f echo1.php
Hello World

# php -dvld.active=1 -f echo2.php
Hello World

# php -dvld.active=1 -dvld.execute=0 -f echo2.php
Hello World

Obviously I'm missing something :)

versions running

php version

# php -v
PHP 5.4.4-14+deb7u14 (cli) (built: Aug 21 2014 08:36:44)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

Running Debian in Virtualbox with Apache 2.2.22


Solution

  • After updating to PHP 5.6.2 I gave it another go and it is running :)

    php version

    # php -v
    PHP 5.6.2 (cli) (built: Oct 17 2014 07:22:10)
    Copyright (c) 1997-2014 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
        with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
    

    install pear

    yum install php56w-pear
    

    installing vld

    pecl install vld
    

    add extension to /etc/php.ini (or in file in /etc/php.d/__.ini)

    #/etc/php.d/vld.ini
    extension=vld.so
    

    restart httpd service and test again (fingers crossed)

     # php -dvld.active=1 -f echo1.php
     Finding entry points
     Branch analysis from position: 0
     Jump found. Position 1 = -2
     filename:       /var/www/html/echo1.php
     function name:  (null)
     number of ops:  4
     compiled vars:  none
     line     #* E I O op                           fetch          ext  return  operands
     -------------------------------------------------------------------------------------
        2     0  E >   CONCAT                                           ~0      'Hello', '+'
              1        CONCAT                                           ~1      ~0, 'World'
              2        ECHO                                                     ~1
        3     3      > RETURN                                                   1
    
     branch: #  0; line:     2-    3; sop:     0; eop:     3; out1:  -2
     path #1: 0,
     Hello World
    

    Boom Baby!

    I don't know why, but it is working as expected :)

    Now the OPCODE adventures can begin (also a love story)