Last active
April 6, 2024 13:10
-
-
Save asminog/08dc7aa5000475dd3fc806a0e4d5ac19 to your computer and use it in GitHub Desktop.
Mac Docker PhpStorm Xdebug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:fpm | |
RUN apt-get update && apt-get install -y libicu-dev libmagickwand-dev libtidy-dev --no-install-recommends \ | |
&& pecl install -o -f imagick redis xdebug \ | |
&& rm -rf /tmp/pear \ | |
&& docker-php-ext-enable imagick redis xdebug \ | |
&& docker-php-ext-install tidy intl pdo pdo_mysql opcache mysqli soap zip exif gd \ | |
&& rm -r /var/lib/apt/lists/* | |
COPY conf/php-fpm/ /usr/local/etc/php-fpm.d/ | |
COPY conf/php/ /usr/local/etc/php/ | |
CMD ["php-fpm"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use xdebug with docker-compose on macOS and PhpStorm | |
1. For your local dev, create a `Dockerfile` that is based on your production image and | |
simply install `xdebug` into it. Exemple: | |
``` | |
FROM php:fpm | |
RUN apt-get update && apt-get install -y libicu-dev libmagickwand-dev libtidy-dev --no-install-recommends \ | |
&& pecl install -o -f imagick redis xdebug \ | |
&& rm -rf /tmp/pear \ | |
&& docker-php-ext-enable imagick redis xdebug \ | |
&& docker-php-ext-install tidy intl pdo pdo_mysql opcache mysqli soap zip exif gd \ | |
&& rm -r /var/lib/apt/lists/* | |
COPY conf/php-fpm/ /usr/local/etc/php-fpm.d/ | |
COPY conf/php/ /usr/local/etc/php/ | |
CMD ["php-fpm"] | |
``` | |
2. Start your container with `docker-compose`: | |
```yaml | |
version: '3' | |
services: | |
web: | |
image: nginx:latest | |
ports: | |
- "80:80" | |
- "443:443" | |
volumes: | |
- ./www:/www:cached | |
... | |
networks: | |
- my-network | |
php: | |
build: ./containers/phpfpm | |
volumes: | |
- ./www/test/data:/www/test/data:cached | |
- ./etc/php/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini | |
networks: | |
- my-network | |
networks: | |
my-network: | |
``` | |
3. In Intellij/PHPStorm go to: `Languages & Frameworks` > `PHP` > `Debug` > `DBGp Proxy` and set the following settings: | |
* `Host`: localhost | |
* `Port`: 9005 | |
Then you're all set and can start listening for PHP Debug connections from your IDE. On the first run it will ask you to map | |
your local directoryies to the `docker` directories, but after that nothing will be required anymore! | |
Happy debugging! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:fpm | |
MAINTAINER asminog <[email protected]> | |
RUN apt-get update && apt-get install -y libicu-dev libmagickwand-dev libtidy-dev --no-install-recommends \ | |
&& pecl install -o -f imagick redis xdebug \ | |
&& rm -rf /tmp/pear \ | |
&& docker-php-ext-enable imagick redis xdebug \ | |
&& docker-php-ext-install tidy intl pdo pdo_mysql opcache mysqli soap zip exif gd\ | |
&& rm -r /var/lib/apt/lists/* | |
COPY conf/php-fpm/ /usr/local/etc/php-fpm.d/ | |
COPY conf/php/ /usr/local/etc/php/ | |
CMD ["php-fpm"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment