The WordPress Playground CLICLI Command Line Interface. Terminal (Bash) in Mac, Command Prompt in Windows, or WP-CLI for WordPress. version 3.0.20 is live! This update introduces powerful new PHPPHP PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. https://www.php.net/manual/en/preface.php. extensions (ImageMagick, SOAP, and AVIF GD Support) that enhance the capabilities of your in-browser WordPress instances, making the playground compatible with plugins and themes that utilize these extensions. Let’s dive into what’s new.
ImageMagick: Your All-in-One Image Processing
Many developers rely on ImageMagick for advanced image manipulation, and now you can use it directly within WordPress Playground. The new ImageMagick extension supports a wide range of formats, including: JPG, PNG, GIF, WEBP (for PHP 8.0 and newer).
This addition increases the PHP bundle size by approximately 4.39MB, a worthwhile trade-off for the power and flexibility it provides. We are also exploring the possibility of shipping ImageMagick in the browser in the future for even better performance.
SOAP Extension: Connecting to Web Services Made Easy
The SOAP extension now supports all PHP builds, allowing you to connect your Playground instances to SOAP-based web services.
Getting started is simple. Here’s a quick example of how you can use the SOAP client to convert temperatures:
<?php
try {
// Create SOAP client that in theory Convert Celsius to Fahrenheit
$client = new SoapClient('<your SOAP endpoint>');
// Submit the values to the client
$celsius = 25;
$params = array('Celsius' => $celsius);
$response = $client->CelsiusToFahrenheit($params);
echo "Input: {$celsius}°C\n";
echo "Result: {$response->CelsiusToFahrenheitResult}°F\n";
} catch (SoapFault $e) {
echo "SOAP Error: " . $e->getMessage() . "\n";
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
In the previous version of @wp-playground/cli, this code, it triggered a Fatal Error, and now it executes successfully.Â
AVIF Support in the GD Extension
The GD extension in WordPress Playground now supports AVIF (AV1 Image File Format) for PHP 8.1 and newer. This enables you to convert images to and from the AVIF format, which provides higher compression, smaller file sizes compared to JPEG, and also supports transparency.
Now WordPress Playground compiles the libaom (AV1 codec) and libavif libraries (version 0.8.2) to WebAssembly, this is a significant technical achievement that brings modern image processing directly to your browser.
Two new functions are available for builders on WordPress Playground from the GD extension:
imagecreatefromavif: Reads an AVIF image and returns aGdImageinstance for manipulation.imageavi:Outputs or saves an image in AVIF format. With the possibility of setting quality and speed compression as parameters.
For more information, check the imageavif and imagecreatefromavif guides.
Practical Example
Convert a JPEG to AVIF:
<?php
// Load JPEG image
$image = imagecreatefromjpeg('photo.jpg');
// Save as AVIF with custom quality
imageavif($image, 'photo.avif', quality: 85);
// Clean up
imagedestroy($image);
echo "Converted photo.jpg to photo.avif\n";
Conclusion
These additions enhance the WordPress Playground’s compatibility with a broader range of plugins and themes. Is there another pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party you feel is essential to the WordPress ecosystem? Please let us know in the comments.Â
To use the WordPress Playground’s latest version, run the command:
$ npx @wp-playground/cli@latest server
To learn more about @wp-playground/cli at the Playground CLI guide. You create! Share your projects and feedback with us in the  #playground Slack channel.