Skip to main content

xdebug - failed to solve with frontend dockerfile.v0: failed to create LLB definition: dockerfile parse error line 45: unknown instruction: ZEND_EXTENSION=XDEBUG.SO

 

How I got here

Running the following Docker command

docker-compose up

Generated this output:

Building php
[+] Building 0.1s (2/2) FINISHED
 => [internal] load build definition from Dockerfile                       0.0s
 => => transferring dockerfile: 1.32kB                                     0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
failed to solve with frontend dockerfile.v0: failed to create LLB definition: dockerfile parse error line 45: unknown instruction: ZEND_EXTENSION=XDEBUG.SO
ERROR: Service 'php' failed to build : Build failed

 

However, as you can see with this output, very quickly the process errors out.

failed to solve with frontend dockerfile.v0: failed to create LLB definition: dockerfile parse error line 45: unknown instruction: ZEND_EXTENSION=XDEBUG.SO

 

First question, is xdebug installed?

Check if xdebug is installed through using

php -i | grep "xdebug"

Nothing to output for me.  So no it's not installed.  So the issue has been discovered for me!  I'll install the extension and then test again.  However, what are my options to install?

 

Options to install xdebug

1. Using Terminal

Head where you'll keep all your php modules like /usr/local/etc/php/modules

Clone the repository:

git clone git://github.com/xdebug/xdebug.git

Head to the repository and go to xdebug:

cd xdebug

Phpize it: phpize

Run the configuration step:

./configure -—enable-xdebug

Now install

make && make install

Now the package will ready to be used. My path was:

/usr/local/etc/php/modules/xdebug/modules/xdebug.so

If you encounter some errors during the steps above, try to prefix the commands with sudo

You now need to tell PHP to load this module on init by editing your php.ini file. However, which php.ini file is currently used and where it is located you can use:

php -i | grep php.ini

This should output something like:

Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini

Now you know where your php.ini file is located. Go ahead and edit it by adding the following line at the end of the file:

zend_extension="/your-path-to-the-module/xdebug.so"

The module should now be installed and used by PHP. Let’s check if this is correct by using this command

php -i | grep "xdebug"

Yep you used this earlier.  This time the response shouldn't be empty. If not you may have edit the wrong php.ini file or type the wrong path to the module.  Go back and cross check the php.ini file and location.

 

 

Related articles

Andrew Fletcher06 May 2024
Exploring historical memory usage monitoring with Sysstat
In the realm of system administration and monitoring, understanding memory usage trends is crucial for maintaining system health and performance. While tools like htop offer real-time insights into memory usage, they lack the capability to provide historical data. So, what if you need to analyze...