symfony/polyfill-php81
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Symfony/polyfill-php81 is a component that backports certain PHP 8.1 features to older versions of PHP. This package provides a more inclusive development environment by allowing developers to take advantage of features that are typically exclusive to PHP 8.1, including array_is_list
, enum_exists
, MYSQLI_REFRESH_REPLICA
constant, ReturnTypeWillChange
, and CURLStringFile
functionalities (though the latter is only usable if PHP >= 7.4).
To effectively use Symfony/polyfill-php81 in your PHP projects, you need to install it via Composer first. Here is an example command to add the package to your project:
composer require symfony/polyfill-php81
Once Symfony/polyfill-php81 is part of your dependencies, PHP 8.1 features will automatically be available for use. You don't need to refer to the polyfill directly in your code β just write your code as if you're running PHP 8.1.
Here's an example where we're using the array_is_list
feature in an older PHP version:
require_once __DIR__ . '/vendor/autoload.php';
$list = [1, 2, 3, 4];
$notList = [1 => 'a', 2 => 'b', 'c' => 3];
var_dump(array_is_list($list)); // Outputs: bool(true)
var_dump(array_is_list($notList)); // Outputs: bool(false)
The documentation for Symfony/polyfill-php81 can be found at the main Polyfill README page which is situated on GitHub. You can access more in-depth information about its purpose, usage, and available features here.