To Install additional PHP extensions you can easily add them to your project by defining them in .ddev/config.yaml file using the webimage_extra_packages tag.
DDEV is an open-source tool for launching local web development environments in minutes. It supports PHP, Node.js, and Python (experimental).
In this tutorial, I will install the php-imap extension as per my requirement in one of the projects.
I’m running a Magento 2.4.2-p1 setup with PHP version 7.4.
Defining Extension in config.yaml
You can specify your required PHP extension in your project’s config.yaml file’s webimage_extra_packages: [php7.4-imap] tag as like below.
name: myproject
type: magento2
docroot: pub
php_version: "7.4"
webserver_type: nginx-fpm
xdebug_enabled: false
additional_hostnames: [whipackaging]
additional_fqdns: []
database:
type: mariadb
version: "10.4"
use_dns_when_possible: true
composer_version: "2"
web_environment: []
webimage_extra_packages: [php7.4-imap]
Now you will be required to restart your project containers to install and activate your custom extension.
To restart the DDEV Project execute the below command inside your project directory.
ddev restart
After a successful restart extension will be downloaded to your project container and will be loaded automatically.
You can verify installed PHP modules/extensions by the below command.
ddev ssh
php -m
This will list all the installed extensions inside your project’s web container.
That’s it, You can install any PHP extensions for your specific PHP version requirement using this approach.
Let me know if you have any questions. Please share this tutorial if you found it very useful.
You may also like :
DDEV Docker: How to change the project PHP version?
DDEV Docker: Configure Cron in Magento 2
Magento 2: How to install and configure n98-magerun2 tool globally?
Leave a Comment