cornishpirate

PHP 7

65 posts in this topic

Have just been playing with PHP 7 RC1 using these instructions as a guide:

 

https://phpdave.wordpress.com/2015/06/15/run-php-7-alpha-on-windows-in-3-steps/

 

Could only use the built-in webserver and php.ini needed tweeking for mysqli but, all in all, a very simple process.

 

Using my heavily modified RC2a system, I managed to load all pages very easily and VERY FAST!

 

Encouraging.

 

 

Share this post


Link to post
Share on other sites

Lucky you :D - I've been cleaning up my custom code while trying to get 5.4/5.5 working.

Share this post


Link to post
Share on other sites

PHP 7? Was PHP 6 ever released? Are you sure that isn't PHP 5.7?

Share this post


Link to post
Share on other sites

Um, OK. If PHP 6 is still bleeding edge and apparently not in production use anywhere, I wonder why anyone would even bother playing with PHP 7 at this time. Whatever.

Share this post


Link to post
Share on other sites

Because it will be released this year and the performance improvement is amazing.

 

Check out the benchmarks.

3 people like this

Share this post


Link to post
Share on other sites

PHP 6 is not going to be released.

Share this post


Link to post
Share on other sites

 

Are you sure that isn't PHP 5.7?

 

There isn't a PHP 5.7.

 

Details about PHP 7.0 RC1 are at http://www.php.net

 

Extract:

 

 

PHP 7.0.0 comes with new version of the Zend Engine with features such as (incomplete list):

  • Improved performance: PHP 7 is up to twice as fast as PHP 5.6
  • Consistent 64-bit support
  • Many fatal errors are now Exceptions
  • Removal of old and unsupported SAPIs and extensions
  • The null coalescing operator (??)
  • Combined comparison Operator (<=>)
  • Return Type Declarations
  • Scalar Type Declarations
  • Anonymous Classes

 

Share this post


Link to post
Share on other sites

PHP 6 is not going to be released.

 

Hmm. So PHP is taking a page from Microsoft and skipping version numbers? Lovely. Just lovely.

Share this post


Link to post
Share on other sites

So i've updated my site to PHP5.6 and it works fine. Will I need to do anything else when PHP7 comes out?

Share this post


Link to post
Share on other sites

Hmm. So PHP is taking a page from Microsoft and skipping version numbers? Lovely. Just lovely.

 

@@MrPhil

 

From what I've heard, Microsoft went from Windows 8.1 to Windows 10 (skipping Windows 9) because ...

 

Way back when, when Microsoft moved from the Windows 95/98 platform to the Windows NT/2000/XP/etc platform, software developers had to put checks in their installation code to determine if they would/could install on a Win95/98 -vs- Win NT/2K/XP OS. So, there were checks for "Windows 9xxx".

 

While current applications may not make these checks, in order to avid problems with legacy code, Microsoft just skipped the Windows 9 version number.

 

Whether this is true or not, I can not say :-

 

Malcolm

Edited by ArtcoInc

Share this post


Link to post
Share on other sites

Whether this is true or not, I can not say :-

 

Yeah, I've heard that account too. Even if it is true (and it could be), it indicates some pretty sloppy coding practices by developers (including Microsoft) in the past. Hard to believe but entirely possible.

Share this post


Link to post
Share on other sites

 

So i've updated my site to PHP5.6 and it works fine. Will I need to do anything else when PHP7 comes out?

 

Should be OK as long as you've moved to MySQli. From memory, I just changed the code to avoid Deprecated warnings on PHP 4 style constructors (methods that have the same name as the class they are defined in). Working well on my test site with PHP7 RC6, but will be giving it a comprehensive test as soon as 7.0 is released, likely to be next week.

Share this post


Link to post
Share on other sites

Thanks for the link to the guide.  I'm only a couple chapters in reading but I like it.

Share this post


Link to post
Share on other sites

PHP7.0 now released and performing extremely well under Plesk 12.5 and nginx.

 

No new problems found yet - will continue testing for at least another month.

 

Very encouraging for the world of PHP.

Share this post


Link to post
Share on other sites

I have also started working on PHP 7 for past 15 days and the most significant advancement which I found out in my application is that it has become quite faster. It takes very less time in loading any page.

It is really great working on PHP 7.

Share this post


Link to post
Share on other sites

So i've updated my site to PHP5.6 and it works fine. Will I need to do anything else when PHP7 comes out?

 

Yes, you will need to modify classes to use __construct classes to prevent DEPRECATED errros, but other than that - it should work just fine when switching from code already compatible with 5.5 (ie. working stable without any deprecated errors on php 5.5, supports UTF-8 and mysqli) to php 7.

 

So, for example, code like this:

  class infoBoxHeading extends tableBox {    
    function infoBoxHeading($contents, $left_corner = true, $right_corner = true, $right_arrow = false) {
global $infobox_header_text, $infobox_header_link;
if (SKIN_INFOBOX_ACTIVE == 'true'){
$infobox_header_text = $contents[0]['text'];
$infobox_header_link = $right_arrow;
}
else {


      $this->table_cellpadding = '0';


      if ($left_corner == true) {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_left.gif');
      } else {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_right_left.gif');
      }
      if ($right_arrow == true) {
        $right_arrow = '<a href="' . $right_arrow . '">' . tep_image(DIR_WS_IMAGES . 'infobox/arrow_right.gif', ICON_ARROW_RIGHT) . '</a>';
      } else {
        $right_arrow = '';
      }
      if ($right_corner == true) {
        $right_corner = $right_arrow . tep_image(DIR_WS_IMAGES . 'infobox/corner_right.gif');
      } else {
        $right_corner = $right_arrow . tep_draw_separator('pixel_trans.gif', '11', '14');
      }


      $info_box_contents = array();
      $info_box_contents[] = array(array('params' => 'height="20" class="infoBoxHeading"',
                                         'text' => $left_corner),
                                   array('params' => 'width="100%" height="20" class="infoBoxHeading"',
                                         'text' => $contents[0]['text']),
                                   array('params' => 'height="14" class="infoBoxHeading" nowrap',
                                         'text' => $right_corner));


      $this->tableBox($info_box_contents, true);
    }
}
  }
 
Must be changed to this:
 
  class infoBoxHeading extends tableBox {
    function __construct($contents, $left_corner = true, $right_corner = true, $right_arrow = false) {
global $infobox_header_text, $infobox_header_link;
if (SKIN_INFOBOX_ACTIVE == 'true'){
$infobox_header_text = $contents[0]['text'];
$infobox_header_link = $right_arrow;
}
else {


      $this->table_cellpadding = '0';


      if ($left_corner == true) {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_left.gif');
      } else {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_right_left.gif');
      }
      if ($right_arrow == true) {
        $right_arrow = '<a href="' . $right_arrow . '">' . tep_image(DIR_WS_IMAGES . 'infobox/arrow_right.gif', ICON_ARROW_RIGHT) . '</a>';
      } else {
        $right_arrow = '';
      }
      if ($right_corner == true) {
        $right_corner = $right_arrow . tep_image(DIR_WS_IMAGES . 'infobox/corner_right.gif');
      } else {
        $right_corner = $right_arrow . tep_draw_separator('pixel_trans.gif', '11', '14');
      }


      $info_box_contents = array();
      $info_box_contents[] = array(array('params' => 'height="20" class="infoBoxHeading"',
                                         'text' => $left_corner),
                                   array('params' => 'width="100%" height="20" class="infoBoxHeading"',
                                         'text' => $contents[0]['text']),
                                   array('params' => 'height="14" class="infoBoxHeading" nowrap',
                                         'text' => $right_corner));


      $this->tableBox($info_box_contents, true);
    }
}
  }

As you can see, the only modification was: function infoBoxHeading changed to function __construct

I highly recommend switching to php 7, if you can.

Edited by dr_lucas
1 person likes this

Share this post


Link to post
Share on other sites

Actually the specific modification example I gave is not so good, because this infoBoxHeading class extends tableBox class and in this case it would be correct to modify tableBox class first from:

class tableBox{
    function tableBox{
        // some code
    }
// more code
}

TO:

class tableBox{
   function __construct(){
    //leave it empty
   }
    function tableBox{
        // some code
    }
// more code
}

 and then on the extended class, do this:

class infoBoxHeading extends tableBox {
    function __construct($contents, $left_corner = true, $right_corner = true, $right_arrow = false) {
global $infobox_header_text, $infobox_header_link;

parent::__construct(); //calling the parent constructor, as tableBox method is being used here in this class

if (SKIN_INFOBOX_ACTIVE == 'true'){
$infobox_header_text = $contents[0]['text'];
$infobox_header_link = $right_arrow;
}
else {


      $this->table_cellpadding = '0';


      if ($left_corner == true) {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_left.gif');
      } else {
        $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_right_left.gif');
      }
      if ($right_arrow == true) {
        $right_arrow = '<a href="' . $right_arrow . '">' . tep_image(DIR_WS_IMAGES . 'infobox/arrow_right.gif', ICON_ARROW_RIGHT) . '</a>';
      } else {
        $right_arrow = '';
      }
      if ($right_corner == true) {
        $right_corner = $right_arrow . tep_image(DIR_WS_IMAGES . 'infobox/corner_right.gif');
      } else {
        $right_corner = $right_arrow . tep_draw_separator('pixel_trans.gif', '11', '14');
      }


      $info_box_contents = array();
      $info_box_contents[] = array(array('params' => 'height="20" class="infoBoxHeading"',
                                         'text' => $left_corner),
                                   array('params' => 'width="100%" height="20" class="infoBoxHeading"',
                                         'text' => $contents[0]['text']),
                                   array('params' => 'height="14" class="infoBoxHeading" nowrap',
                                         'text' => $right_corner));


      $this->tableBox($info_box_contents, true);
    }
}
  }

Note that we don't only modify the method name here from infoBoxHeading to __construct, but we are also calling the parent construct via parent::__construct();

1 person likes this

Share this post


Link to post
Share on other sites

just for the fun of it, tonight after midnight I changed version to php7 for a short while

 

I had a (custom) badly coded break statement in application top

 

I had to change this line from single to double quotes

if (!tep_session_is_registered("SESSION_USER_AGENT")) {

 

I also use apc caching and had to change the references to apc_xxx to apcu_xxx

 

Now, with the little tests I made on home page, categories page and product info page, it only gave me the construct warnings.

 

So overall pretty happy. Fix the constructors, I'll take some performance baseline numbers and readup on what potentially can go wrong before taking the plunge.

1 person likes this

Share this post


Link to post
Share on other sites

I had to change this line from single to double quotes

if (!tep_session_is_registered("SESSION_USER_AGENT")) {

Actually, a macro name (defined constant) should never be within quotes. They are stand-alone strings.

if (!tep_session_is_registered(SESSION_USER_AGENT)) {
2 people like this

Share this post


Link to post
Share on other sites

@@MrPhil @@bruyndoncx

 

That is mostly true.  I was caught out doing something recently;

if (defined(SOME_TEXT)) echo SOME_TEXT;

needs to be

if (defined('SOME_TEXT')) echo SOME_TEXT;

The lack of apostrophes stumped me for an afternoon lol

Share this post


Link to post
Share on other sites

it will be released this year and the performance improvement is amazing.

 

PHP 7 has already been released @ Nov-Dec 2015, and yes, it does have an excellent performance improvement.

Share this post


Link to post
Share on other sites

After exhaustive testing on our preview site, I took a deep breath and invoked PHP 7.05 on the live site yesterday.

 

Pleased to report that all went extremely well and the performance improvement is considerable. No horrible suprises in the error logs either.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now