rubenmartindev/prestashop-version-checker

A lightweight library to check and compare PrestaShop versions with a fluent API

Maintainers

Package info

github.com/rubenmartindev/prestashop-version-checker

pkg:composer/rubenmartindev/prestashop-version-checker

Transparency log

Statistics

Installs: 18

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.1 2026-05-31 10:05 UTC

This package is auto-updated.

Last update: 2026-07-01 00:07:50 UTC


README

A lightweight library to check and compare PrestaShop versions with a fluent API.

Installation

composer require rubenmartindev/prestashop-version-checker

Requirements

  • PHP >= 5.6.0
  • PrestaShop (any version)

Usage

Using the helper function (recommended)

// Check if PrestaShop version is less than 1.7
if (is_ps_version('<1.7')) {
    // PrestaShop 1.6.x code
}

// Check if PrestaShop version is greater than or equal to 1.7
if (is_ps_version('>=1.7')) {
    // PrestaShop 1.7+ code
}

Using the class directly

use RubenMartinDev\PrestaShopVersionChecker\PrestaShopVersionChecker;

if (PrestaShopVersionChecker::is('<1.7')) {
    // PrestaShop 1.6.x code
}

Supported operators

Operator Description
< Less than
<= Less than or equal
> Greater than
>= Greater than or equal
== Equal
= Equal (alias)
!= Not equal
<> Not equal (alias)
lt Less than
le Less than or equal
gt Greater than
ge Greater than or equal
eq Equal
ne Not equal

Shorthand methods

Warning

The shorthand methods are deprecated and will be removed in the next major release.

use RubenMartinDev\PrestaShopVersionChecker\PrestaShopVersionChecker;

// Less than
PrestaShopVersionChecker::lt('1.7');    // Same as is('<1.7')

// Less than or equal
PrestaShopVersionChecker::lte('1.7');   // Same as is('<=1.7')

// Greater than
PrestaShopVersionChecker::gt('1.6');    // Same as is('>1.6')

// Greater than or equal
PrestaShopVersionChecker::gte('1.7');   // Same as is('>=1.7')

// Equal
PrestaShopVersionChecker::eq('1.7.8');  // Same as is('==1.7.8')

// Not equal
PrestaShopVersionChecker::neq('1.6');   // Same as is('!=1.6')

Check if the compare is valid

use RubenMartinDev\PrestaShopVersionChecker\PrestaShopVersionChecker;

PrestaShopVersionChecker::isCompareValid('<1.7');    // true
PrestaShopVersionChecker::isCompareValid('gt 1.7');  // true

PrestaShopVersionChecker::isCompareValid(1.7);       // false
PrestaShopVersionChecker::isCompareValid('foobar');  // false

Real-world example

class MyModule extends Module
{
    public function hookDisplayHeader()
    {
        if (is_ps_version('<1.7')) {
            return $this->display(__FILE__, 'views/templates/hook/header_16.tpl');
        }

        return $this->display(__FILE__, 'views/templates/hook/header.tpl');
    }
}