PHPVersion.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Grav\Plugin\Problems;
  3. use Grav\Plugin\Problems\Base\Problem;
  4. class PHPVersion extends Problem
  5. {
  6. public function __construct()
  7. {
  8. $this->id = 'PHP Minimum Version';
  9. $this->class = get_class($this);
  10. $this->order = 102;
  11. $this->level = Problem::LEVEL_CRITICAL;
  12. $this->status = false;
  13. $this->help = 'https://getgrav.org/blog/raising-php-requirements-2018';
  14. }
  15. public function process()
  16. {
  17. $min_php_version = defined('GRAV_PHP_MIN') ? GRAV_PHP_MIN : '5.6.4';
  18. $your_php_version = phpversion();
  19. $msg = "Your PHP <strong>%s</strong> is %s than the minimum of <strong>%s</strong> required";
  20. // Check PHP version
  21. if (version_compare($your_php_version, $min_php_version, '<')) {
  22. $this->msg = sprintf($msg, $your_php_version, 'less', $min_php_version);
  23. } else {
  24. $this->msg = sprintf($msg, $your_php_version, 'greater', $min_php_version);
  25. $this->status = true;
  26. }
  27. return $this;
  28. }
  29. }