首页 > 解决方案 > Prestashop module - Requires PHP 7.1 at least

问题描述

I can't find any information on that. Is it possible on a Prestashop module to prevent installation/upgrade to a module that requires PHP 7.1?

I can exit the process with but it installs the plugin anyway.

<?php
if (version_compare(PHP_VERSION, '7.1.0', '<')) {
    exit;
}

WordPress has a good manner to handle this, by adding a 'Requires PHP' line to readme.

Thanks in advance.

EDIT: I opened an issue in their GitHub: https://github.com/PrestaShop/PrestaShop/issues/25578

标签: phpprestashop

解决方案


只需将其添加到模块的主文件中即可

if (!defined('_PS_VERSION_') || version_compare(PHP_VERSION, '7.1.0', '<')
    exit;
}

class CrezzurModule extends Module
{
    public function __construct()
    {
        $this->name = 'crezzurmodule';
        $this->tab = 'front_office_features';
        $this->version = '1.0.4';
        ...

推荐阅读