Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 3.0 migration PHP 5.5 to PHP 7.1 : "A PHP accelerator should be installed > Install and/or enable a PHP accelerator (highly recommended)"?

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

like image 719
nyluje Avatar asked Jan 24 '17 09:01

nyluje


1 Answers

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"
        }
    },
}
like image 91
nyluje Avatar answered Nov 02 '22 21:11

nyluje