Coder Social home page Coder Social logo

geerlingguy / ansible-role-php-xdebug Goto Github PK

View Code? Open in Web Editor NEW
41.0 5.0 48.0 85 KB

Ansible Role - PHP Xdebug

Home Page: https://galaxy.ansible.com/geerlingguy/php-xdebug/

License: MIT License

PHP 36.54% Jinja 63.46%
ansible role php xdebug debug debugger

ansible-role-php-xdebug's Introduction

Ansible Role: PHP-XDebug

CI

Installs PHP XDebug on Linux servers.

Requirements

Prior to running this role, make sure the php-devel and @Development Tools (for RHEL/CentOS) or php5-dev + build-essential packages (for Debian/Ubuntu) are present on the system, as they are required for the build of Xdebug.

Role Variables

Available variables are listed below, along with default values (see defaults/main.yml):

workspace: /root

Where Xdebug setup files will be downloaded and built.

php_xdebug_version: 3.2.1

The version of Xdebug to be installed (see Updates for a current listing).

php_xdebug_default_enable: 1
php_xdebug_coverage_enable: 1

Whether to enable XDebug coverage and default exception handling or not. Disable these for slightly improved PHP performance, enable these to use XDebug to the fullest extent.

php_xdebug_module_path: /usr/lib64/php/modules

The path where xdebug.so will be installed.

php_xdebug_remote_enable: "false"

Whether remote debugging is enabled.

php_xdebug_remote_connect_back: "false"

If this is set to true, Xdebug will respond to any request from any IP address; use only for local development on non-public installations!

php_xdebug_remote_host: localhost
php_xdebug_remote_port: "9000"

The host and port on which Xdebug will listen.

php_xdebug_remote_log: /tmp/xdebug.log

The location of the xdebug log (useful if you're having trouble connecting).

php_xdebug_idekey: sublime.xdebug

The IDE key to use in the URL when making Xdebug requests (e.g. http://example.local/?XDEBUG_SESSION_START=sublime.xdebug).

php_xdebug_max_nesting_level: 256

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

php_xdebug_cli_disable: false

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

Dependencies

  • geerlingguy.php

Example Playbook

- hosts: webservers
  roles:
    - { role: geerlingguy.php-xdebug }

License

MIT / BSD

Author Information

This role was created in 2014 by Jeff Geerling, author of Ansible for DevOps.

ansible-role-php-xdebug's People

Contributors

andrewhowdencom avatar geerlingguy avatar iainhouston avatar kentr avatar lewisw avatar lluisi avatar mglaman avatar oxyc avatar thom8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ansible-role-php-xdebug's Issues

Document all dependencies

This role also needs build tools. php-devel + @Development Tools on CentOS and php5-dev + build-essential on Debian-like.

Can not disabled for the CLI

I find that this role not use php_xdebug_cli_enable anymore, but document still explain the usage of php_xdebug_cli_enable. It confused me.

Install is broken with PHP 5.4 in some cases with geerlinguy.php

I'm using your geerlinguy.php package to install php 7, when I try to install xdebug I get this error:

ailed: [lsv3] (item=php-fpm) => {"changed": false, "item": "php-fpm", "msg": "Error: Package: php-fpm-5.4.16-43.el7_4.x86_64 (updates)\n Requires: php-common(x86-64) = 5.4.16-43.el7_4\n Installed: php-common-7.2.2-1.el7.remi.x86_64 (@remi-php72)\n php-common(x86-64) = 7.2.2-1.el7.remi\n Available: php-common-5.4.16-42.el7.x86_64 (base)\n php-common(x86-64) = 5.4.16-42.el7\n Available: php-common-5.4.16-43.el7_4.x86_64 (updates)\n php-common(x86-64) = 5.4.16-43.el7_4\n", "rc": 1, "results": ["Loaded plugins: fastestmirror\nLoading mirror speeds from cached hostfile\n * base: mirrors.clouvider.net\n * epel: mirrors.coreix.net\n * extras: mirrors.coreix.net\n * remi-safe: mirror.netweaver.uk\n * updates: mirrors.clouvider.net\nResolving Dependencies\n--> Running transaction check\n---> Package php-fpm.x86_64 0:5.4.16-43.el7_4 will be installed\n--> Processing Dependency: php-common(x86-64) = 5.4.16-43.el7_4 for package: php-fpm-5.4.16-43.el7_4.x86_64\n--> Finished Dependency Resolution\n You could try using --skip-broken to work around the problem\n You could try running: rpm -Va --nofiles --nodigest\n"]}

Seems this package is trying to install php packages from 5.4 version.

Add bash scripts to enable / disable xdebug

I'd suggest that there should be a param

enable_xdebug_so: true

That would be check if you want the role enable the library directly.

And also add a bash script what you could use to call on host to restore/remove the lines.

Doesn't work with PHP 7.1

On Ubuntu 14.04 with PHP 7.1

failed: [drupalvm_php] (item=./configure) => {"changed": true, "cmd": "./configure", "delta": "0:00:01.001059", "end": "2016-12-10 01:18:03.169708", "failed": true, "item": "./configure", "rc": 1, "start": "2016-12-10 01:18:02.168649", "stderr": "configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.\nconfigure: error: not supported. Need a PHP version >= 5.4.0 and < 7.1.0 (found 7.1.0-3+deb.sury.org~trusty+1)", "stdout": "checking for grep that handles long lines and -e... /bin/grep\nchecking for egrep... /bin/grep -E\nchecking for a sed that does not truncate output... /bin/sed\nchecking for cc... cc\nchecking whether the C compiler works... yes\nchecking for C compiler default output file name... a.out\nchecking for suffix of executables... \nchecking whether we are cross compiling... no\nchecking for suffix of object files... o\nchecking whether we are using the GNU C compiler... yes\nchecking whether cc accepts -g... yes\nchecking for cc option to accept ISO C89... none needed\nchecking how to run the C preprocessor... cc -E\nchecking for icc... no\nchecking for suncc... no\nchecking whether cc understands -c and -o together... yes\nchecking for system library directory... lib\nchecking if compiler supports -R... no\nchecking if compiler supports -Wl,-rpath,... yes\nchecking build system type... x86_64-unknown-linux-gnu\nchecking host system type... x86_64-unknown-linux-gnu\nchecking target system type... x86_64-unknown-linux-gnu\nchecking for PHP prefix... /usr\nchecking for PHP includes... -I/usr/include/php/20160303 -I/usr/include/php/20160303/main -I/usr/include/php/20160303/TSRM -I/usr/include/php/20160303/Zend -I/usr/include/php/20160303/ext -I/usr/include/php/20160303/ext/date/lib\nchecking for PHP extension directory... /usr/lib/php/20160303\nchecking for PHP installed headers prefix... /usr/include/php/20160303\nchecking if debug is enabled... no\nchecking if zts is enabled... no\nchecking for re2c... no\nchecking for gawk... no\nchecking for nawk... nawk\nchecking if nawk is broken... no\nchecking whether to enable Xdebug support... yes, shared\nchecking Check for supported PHP versions... ", "stdout_lines": ["checking for grep that handles long lines and -e... /bin/grep", "checking for egrep... /bin/grep -E", "checking for a sed that does not truncate output... /bin/sed", "checking for cc... cc", "checking whether the C compiler works... yes", "checking for C compiler default output file name... a.out", "checking for suffix of executables... ", "checking whether we are cross compiling... no", "checking for suffix of object files... o", "checking whether we are using the GNU C compiler... yes", "checking whether cc accepts -g... yes", "checking for cc option to accept ISO C89... none needed", "checking how to run the C preprocessor... cc -E", "checking for icc... no", "checking for suncc... no", "checking whether cc understands -c and -o together... yes", "checking for system library directory... lib", "checking if compiler supports -R... no", "checking if compiler supports -Wl,-rpath,... yes", "checking build system type... x86_64-unknown-linux-gnu", "checking host system type... x86_64-unknown-linux-gnu", "checking target system type... x86_64-unknown-linux-gnu", "checking for PHP prefix... /usr", "checking for PHP includes... -I/usr/include/php/20160303 -I/usr/include/php/20160303/main -I/usr/include/php/20160303/TSRM -I/usr/include/php/20160303/Zend -I/usr/include/php/20160303/ext -I/usr/include/php/20160303/ext/date/lib", "checking for PHP extension directory... /usr/lib/php/20160303", "checking for PHP installed headers prefix... /usr/include/php/20160303", "checking if debug is enabled... no", "checking if zts is enabled... no", "checking for re2c... no", "checking for gawk... no", "checking for nawk... nawk", "checking if nawk is broken... no", "checking whether to enable Xdebug support... yes, shared", "checking Check for supported PHP versions... "], "warnings": []}
failed: [drupalvm_php] (item=make) => {"changed": true, "cmd": "make", "delta": "0:00:00.011378", "end": "2016-12-10 01:18:03.442383", "failed": true, "item": "make", "rc": 2, "start": "2016-12-10 01:18:03.431005", "stderr": "make: *** No targets specified and no makefile found. Stop.", "stdout": "", "stdout_lines": [], "warnings": []}

oerdnj/deb.sury.org#444

A few php .ini files are in the wrong place on Ubuntu

Xdebug wasn't working for me immediately after install. Turns out that xdebug.ini was in /etc/php5/conf.d but Apache only cared about /etc/php5/apache2/conf.d (screenshot showing that: https://www.dropbox.com/s/3zgzpbrevy8f035/Screenshot%202015-04-17%2012.38.36.png?dl=0). Moving xdebug.ini into that directory and restarting apache fixed it.

I noticed that xhprof.ini and 20-apc.ini were also in the first directory, but not sure if those were broken as well.

This is on Ubuntu 14.04.

Could you update to php7-0 ?

As subject says. Any plans for updating ?

Also you should allow us to provide url for xdebug, not only version. They changed ...2.4.0.tgz into 2.4.0.tar.gz :) So it wont download.

Add support for profiler

I would like to see this role support the profiling variables xdebug supports natively.

I understand you've provided the same functionality via xhprof, but it does lack any form of editor/ide integration for analysis.

Is this something you're prepared to consider for future implementation?

This could be done by making the following variables available for configuration:

xdebug.profiler_enable = 1;
xdebug.profiler_enable_trigger = 1;
xdebug.profiler_output_dir = "DIRECTORY_FOR_OUTPUT"
xdebug.profiler_output_name = cachegrind.out

Similarly the tracing functionality of xdebug could be configurable via variable - It's another thing I would like to see here...

xdebug.trace_output_name = cachegrind.out
xdebug.trace_enable_trigger = 1;
xdebug.trace_output_dir = "DIRECTORY_FOR_OUTPUT"

Error - Copy xdebug ini into main extension config folder

Hello,
Getting the following error when provisioning a new vm.


TASK: [geerlingguy.php-xdebug | Copy xdebug ini into main extension config folder.] ***
fatal: [drupalvm] => with_items expects a list or a set

FATAL: all hosts have already failed -- aborting

Drupal vm is centos7 v1.1.1

Thanks,
Sam

Upgrade to 3.0.0

I was in the middle of a PR but the changes seem big so may warrant a discussion a bit.
https://php.watch/articles/xdebug2-vs-3-benchmark
https://xdebug.org/docs/upgrade_guide

Looks like much of the config has been replaced by a specific "mode"

xdebug.remote_enable=1
xdebug.default_enable=0
xdebug.profiler_enable=0
xdebug.auto_trace=0
xdebug.coverage_enable=0

becomes

xdebug.mode=debug

Default port changed from 9000 to 9003 (which is great because fpm always collides with it)

The xdebug.remote_autostart setting has been removed. Instead, set xdebug.start_with_request to yes.

So the big question, how much BC are you looking for @geerlingguy ?

Cannot use php to disable xdebug

Trying to disable the xdebug plugin to improve composer performance:

php -dextension=/usr/lib/php5/modules/xdebug.so
PHP Warning:  Xdebug MUST be loaded as a Zend extension in Unknown on line 0
PHP Warning:  Module 'xdebug' already loaded in Unknown on line 0

The requested handler 'restart webserver' was not found

I'm running the playbook with the following config:

vars/xdebug.yml:

php_xdebug_version: 2.2.5

php_xdebug_coverage_enable: 1
php_xdebug_default_enable: 1
php_xdebug_cli_enable: 1

php_xdebug_remote_enable: "true"
php_xdebug_remote_connect_back: "true"
php_xdebug_remote_host: 10.0.2.15
php_xdebug_remote_port: "9000"
php_xdebug_remote_log: /tmp/xdebug.log
php_xdebug_remote_autostart: "false"

php_xdebug_max_nesting_level: 256

php_xdebug_idekey: "PHPSTORM"

But I keep getting the The requested handler 'restart webserver' was not found error.

(Part of) the playbook:

- hosts: webdev
  become: yes
  user: vagrant
  vars_files:
  - vars/xdebug.yml
  - vars/apache-dev.yml
  roles:
  - { role: geerlingguy.apache }
  - { role: geerlingguy.php-xdebug }

How can this issue be fixed?

Task "Move Xdebug module into place" failing

Problem / motivation

I'm getting repeated errors at the Move Xdebug module into place task.

The error message is

fatal: [drupalvm]: FAILED! => {"changed": false, "failed": true, "msg": "Unable to find '/root/php7.0/xdebug-2.5.0/modules/xdebug.so' in expected paths."}

Steps to reproduce

  1. Clone DrupalVM
  2. Uncomment xdebug in installed_extras.
  3. vagrant up.

Suggested fix

Revert the Move Xdebug module into place task so that it uses the shell module instead of the copy module.

Maybe copy module is working in some cases here, but the Ansible docs claim that it's for copying a file from the local machine to the remote node, not for copying a file within the remote node.

Limited testing shows that this change solves the problem in my case.

PR coming.

Configuration option to completely unload xdebug extension for CLI

Following up on conversation here: geerlingguy/drupal-vm#1545

Having xdebug loaded for the CLI (even if it's not enabled) has a significant performance impact: acquia/blt#1983 (comment)

Currently, if you set php_xdebug_default_enable: 0 or php_xdebug_cli_enable: 0 in config.yml, xdebug will be disabled for the CLI, but will still be loaded, causing said performance issues.

There should be a way to have the xdebug extension completely unloaded for CLI by default.

Ansible 2.x issues

Getting the following:

TASK [geerlingguy.php-xdebug : Untar Xdebug.] **********************************
changed: [drupalvm]
 [WARNING]: Consider using unarchive module rather than running tar

Add option 'xdebug_enabled' (or something similar)

XDebug is great to have most of the time—however, there are times when I like having it installed/available, but not currently loaded, so I can do certain testing, or get logs/reports in a way that's not influenced by XDebug.

Typically, one would simply remove XDebug entirely (or not use this role) if they don't want it... but for development VMs, I often have it installed, and like to enable and disable it.

Xdebug Version not upped

The task Move Xdebug module into place gets skipped when a new version is inserted. Therefore, you have to manually move the xdebug.so into place if you upgrade the xdebug version. Any chance this could check to see if a new version has been updated?

Resets some php.ini settings

playbook basically looks like this:

- role: geerlingguy.php-versions
  php_version: "7.1"

- role: geerlingguy.php
  php_version: "7.1"
  php_packages:
        - php-cli
        - php-dev
        - php-mysql
        - libapache2-mod-php7.1
        - php-apcu
        - php-mcrypt
        - php-xml
        - php-mbstring
        - php-sqlite3
  php_webserver_daemon: "apache2"
  php_memory_limit: "1024M"
  php_date_timezone: "Europe/Berlin"

- role: geerlingguy.php-xdebug
  php_xdebug_remote_enable: "true"
  php_xdebug_remote_connect_back: "true"
  php_xdebug_idekey: "vagrant"

After everything is done, the timezone will be reset to "America/Chicago". If i comment out the xdebug role, the timezone will be correctly set to "Europe/Berlin".

Destination directory /etc/php.d does not exist

Failing. I'm using your ansible-role-php.

TASK: [geerlingguy.php-xdebug | Move Xdebug module into place.] ***************
failed: [default] => {"changed": true, "cmd": "cp /root/xdebug-2.2.4/modules/xdebug.so /usr/lib64/php/modules ", "delta": "0:00:00.015167", "end": "2014-06-19 20:48:21.315685", "item": "", "rc": 1, "start": "2014-06-19 20:48:21.300518"}
stderr: cp: cannot create regular file `/usr/lib64/php/modules': No such file or directory

I solved that one by changing php_xdebug_module_path to /usr/lib/php5/modules, but I can't change the path for the other one:

TASK: [geerlingguy.php-xdebug | Copy xdebug INI into php.d folder.] ***********
failed: [default] => {"failed": true, "item": ""}
msg: Destination directory /etc/php.d does not exist

The correct path (for me, after ansible-role-php sets up PHP) appears to be "/etc/php5/conf.d/".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.