Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling xdebug for CLI SAPI on Debian/Ubuntu. #54

Merged
merged 1 commit into from
Oct 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ The IDE key to use in the URL when making Xdebug requests (e.g. `http://example.

The maximimum function nesting level before Xdebug bails and throws a fatal exception.

php_xdebug_cli_disable: no

(Debian/Ubuntu ONLY) Disable xdebug for the CLI SAPI.

## Dependencies

- geerlingguy.php
Expand Down
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ php_xdebug_idekey: sublime.xdebug

php_xdebug_max_nesting_level: 256

# Only used on Debian/Ubuntu.
php_xdebug_cli_disable: no
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be willing to add this in Debian/Ubuntu-specific without something similar for Red Hat/etc... but I want to try to make it an equitable option for CentOS users at least. If nobody else can take a crack at it, I will soon, I just don't have the time tonight.

Copy link

@danepowell danepowell Oct 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how this would be possible on CentOS without substantial changes to how PHP is invoked.

I've never worked with CentOS before, but after a brief investigation it appears that PHP config files can't distinguish between different execution contexts (CLI vs FPM) like they can on Ubuntu. Instead, you'd have to pass a unique CLI-specific configuration file as an argument to php, which seems like a pretty big change just to support this one use case.

A brief Google seems to confirm this: https://gagor.pl/2014/05/changing-default-php-ini-file-for-php-cli-on-centos/

10 changes: 10 additions & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@
owner: root
group: root
mode: 0644
when: "'cli' not in item or ('cli' in item and not php_xdebug_cli_disable)"
with_items: "{{ php_extension_conf_paths }}"
notify:
- restart webserver
- restart php-fpm

- name: Disable xdebug for PHP CLI.
file:
path: "/etc/php/{{ php_version }}/cli/conf.d/{{ php_xdebug_config_filename }}"
state: absent
when: ansible_os_family == 'Debian' and php_xdebug_cli_disable
notify:
- restart webserver
- restart php-fpm