Download the PHP package italystrap/platform-requirements-check without Composer

On this page you can find all versions of the php package italystrap/platform-requirements-check. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package platform-requirements-check

Platform Requirements Check

Build status Latest Stable Version Total Downloads Latest Unstable Version License PHP from Packagist Mutation testing badge

Platform Requirements Check is a PHP library that allows you to check system requirements for your PHP project or plugin. The library provides a simple interface that can be used to define and check system requirements like minimum and maximum PHP versions, PHP extensions, and any other specific project requirements.

This library support PHP 7.4 or higher. If you need to support PHP <7.4 you can use the original Minimum Requirement library where this is forked from.

Table Of Contents

Installation

The best way to use this package is through Composer:

This package adheres to the SemVer specification and will be fully backward compatible between minor versions.

Basic Usage

The first important thing to do is to require the autoloader file included in this package before the Composer autoloader:

This file will register a PSR-4 autoloader for the ItalyStrap\PlatformRequirementsCheck namespace. You need to require it before everything else because this library can't rely on the Composer autoloader since the Composer autoloader itself is loaded to late in the application bootstrap process, so you need to perform PlatformRequirementsCheck before all and if all requirements are met then you can load the Composer autoloader.

The library provides a RequirementInterface interface which you can use to define your system requirements. Implement this interface to define a new requirement.

I don't know your project so I don't know all the cases you need to add your own requirement, in any case maybe using an anonymous class could be a good idea if you need only a single requirement.

The library also provides two traits, WithNameTrait and WithConstraintTrait, which can be used to simplify the creation of new requirement classes.

Additionally, there's a Requirements class that can be used to group together and check a set of requirements.

RangeVersionRequirement is a concrete class that implements RequirementInterface. This class checks if the current version of a certain component (e.g., PHP, Theme or plugin) is within a version range. Use RangeVersionRequirement to define a version range-based requirement.

Because the min and max versions are optional, if you omit one of them the one you omitted will be replaced with the current version of the component you are checking.

Let's see an example:

You get the point.

Now, one last thing, if you need for example to check for maximum PHP version to be less than 8.1 but greater than 8.0 because right now the operator used for checking the maximum version is '<=' you can do by appending PHP_INT_MAX to the max version like '8.0.' . PHP_INT_MAX, so any version less than 8.1 but max than 8.0 will be valid, yes I know, it's a little bit hacky but if you do not like this just create your own requirement class, and you're done.

If $requirement->check() is false then you can get the error message with $requirement->errorMessage() and print it if you need to.

For the basic usage, that's all you need to know, I think.

Advanced Usage

If you want to use this library in your WordPress plugin, you can use it like this:

You could check in the main file or like me create a bootstrap.php file to do all the rest of the stuff.

If the requirements are not met, you can choose to deactivate the plugin or theme, or you can choose to show an error message to the user and let them decide what to do, you have the power.

Right now I decided to not include the check for required plugins like the original package does, if I have some time in the future I could do it.

Contributing

All feedback / bug reports / pull requests are welcome.

License

Copyright (c) 2019 Enea Overclokk, ItalyStrap

This code is licensed under the MIT.


All versions of platform-requirements-check with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package italystrap/platform-requirements-check contains the following files

Loading the files please wait ....