9

I want to upgrade PHP5.5 to 7.1 in a SYMFONY 3.0 Project.

I have been checking the "php.ini" file to get the right result.

One last thing is unresolved: Under PHP5.5, I used the extension accelerator php_apcu.dll. This is not maintained in PHP7.

I was looking for alternative and I read here that the accelerator is no longer needed in PHP7 because already embedded in it.

When I do a CLI: "php bin/symfony_requirements", the following message appears:

A PHP accelerator should be installed > Install and/or enable a PHP > accelerator (highly recommended)

As I understand it, I don't need to add a new extension but I can enable somewhow the accelerator in PHP7.

Does someone know if an "accelerator" parameter needs to be set to "true" in PHP7, or does it run by default (and Symfony error message should be ignored), or a new extension (different from the deprecated APC as the wiki page explains) should be installed?

UPDATES: Following comments received on the question I added to my "php.ini" the following setting:

opcache.enable=1 
opcache.enable_cli=1 
opcache.memory_consumption=128 
opcache.interned_strings_buffer=8 
opcache.max_accelerated_files=2000 
opcache.revalidate_freq=60 
opcache.fast_shutdown=1 

I restarted the Apache service and When I do a CLI: "php bin/symfony_requirements", I still receive the following message:

A PHP accelerator should be installed > Install and/or enable a PHP > accelerator (highly recommended)

Updates regarding @LBA required info: I did a CLI "composer update" in the folder of my Symfony project.

Then when I do a CLI: "php bin/symfony_requirements", I get:

PHP Notice: A non well formed numeric value encountered in D:\Application\Apache24\htdocs\symf\my_symf_project\var\SymfonyRequirements.php on line 759

Notice: A non well formed numeric value encountered in D:\Application\Apache24\htdocs\symf\my_symf_project\var\SymfonyRequirements.php on line 759

Symfony2 Requirements Checker ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

PHP is using the following php.ini file: D:\Application\php7\php.ini

Checking Symfony requirements: ................W...............W.......

[OK] Your system is ready to run Symfony2 projects

Optional recommendations to improve your setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  • Requirements file should be up-to-date

    Your requirements file is outdated. Run composer install and re-check your configuration.

  • a PHP accelerator should be installed

    Install and/or enable a PHP accelerator (highly recommended).

Note The command console could use a different php.ini file ~~~~ than the one used with your web server. To be on the safe side, please check the requirements from your web server using the web/config.php script.

About the setting of the environment (on Windows10):

  1. Previously to anything, I had changed my "path" environment variable with "[folder location of php7]\php7\" and when I launch a "php -v" I get:

PHP 7.1.1 (cli) (built: Jan 18 2017 18:38:49) ( ZTS MSVC14 (Visual C++ 2015) x64 ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

The composer file in the symfony project looks like that:

    "require": {
        "php": ">=5.5.9",
...}

And if I try to change the value to "php":">=7.1.0" and launch "composer update" it gives:

Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages.

Problem 1 - This package requires php >=7.1.0 but your PHP version (5.5.9) does not satisfy that requirement.

So there is something wrong with my environement variable with Symfony.

If I do phpinfo(), not in Symfony but with a regular PHP server page, it states on top: PHP Version 7.1.1

nyluje
  • 3,573
  • 7
  • 37
  • 67
  • http://symfony.com/doc/current/performance.html#use-a-byte-code-cache-e-g-opcache – Veve Jan 24 '17 at 09:55
  • 2
    That warning about an accelerator usually applied to a caching engine. You can ignore it or install something like APC. – pogeybait Jan 24 '17 at 10:17
  • are you sure opcache is enabled in your php.ini? – LBA Jan 24 '17 at 10:18
  • I read @Veve link and try to figure out how the opcache should be enabled in php.ini with php.net/manual, if you have recommendations about it (that would save me some reading and go straight to what I need) I would take it. – nyluje Jan 24 '17 at 10:22
  • http://php.net/manual/en/opcache.installation.php#opcache.installation.recommended – Veve Jan 24 '17 at 10:23
  • I have a "; Determines if Zend OPCache is enabled ;opcache.enable=0" in my php.ini and I wonder If I should uncomment the lign and change it to opcache.enable=1? – nyluje Jan 24 '17 at 10:26
  • I updated my question with the changes in the php.ini to activate opcache, but still get the warning message. – nyluje Jan 24 '17 at 10:36
  • 2
    are you sure you updated the correct php.ini (and not the one used for PHP cli)? – LBA Jan 24 '17 at 10:38
  • @LBA I've looked for another "php.ini" and none were found, It seems that it takes the one under "/php7/" folder as it should (and it notifies that it uses the correct "php.ini" path+files when launching "bin/symfony_requirements"), I did a "composer update" (that I required for other stuff too) and hoping it could fix such problem as the one you are suggesting but it did not change anything, moreover now, on top of stating that I should turn on an "accelerator" , it recommends me to do a "composer update" (which I ve just done). – nyluje Jan 24 '17 at 11:39
  • are you sure as well that you upgraded to php 7 correctly? so that apache is using the correct php mods? – LBA Jan 24 '17 at 13:31
  • is it composer update or self-update? what is the exact message? – LBA Jan 24 '17 at 13:31
  • to me it looks like your environment is not set up correctly - check this before and then ask for help – LBA Jan 24 '17 at 13:32
  • @LBA I ve updated the question, you are right I think. I try to figure out why the php7 is not recognised when running with Symfony project also it seems to work alright if I am not going thru Symfony. – nyluje Jan 24 '17 at 14:04

1 Answers1

10

Here is the solution, 2 things I needed to do:

1st: It needs indeed opcache.

In the php.ini, moreover than the settings that are instructed to do in symfony documentation and php manual. I had forgotten to add the extension to use in the php.ini:

zend_extension="[your path to php7]\php7\ext\php_opcache.dll"

(well it is in the php manual documentation here)

2nd: On symfony side, I had to update the following settings in [project path]\composer.json to make sure Symfony uses PHP7:

{
    "require": {
        "php": ">=7.1.1",
         ....
    },
    ....
    "config": {
        "platform": {
            "php": "7.1.1"
        }
    },
}
nyluje
  • 3,573
  • 7
  • 37
  • 67