{"id":198,"date":"2018-03-18T18:17:48","date_gmt":"2018-03-18T17:17:48","guid":{"rendered":"http:\/\/test.ekiwi.de\/?p=198"},"modified":"2021-08-23T13:43:05","modified_gmt":"2021-08-23T11:43:05","slug":"php-debugging-in-xampp-und-uestudio-einrichten","status":"publish","type":"post","link":"https:\/\/ekiwi.de\/index.php\/198\/php-debugging-in-xampp-und-uestudio-einrichten\/","title":{"rendered":"PHP-Debugging in XAMPP und UEStudio einrichten"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Inhalt<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ekiwi.de\/index.php\/198\/php-debugging-in-xampp-und-uestudio-einrichten\/#Video_Anleitung\" >Video Anleitung<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ekiwi.de\/index.php\/198\/php-debugging-in-xampp-und-uestudio-einrichten\/#Anleitung\" >Anleitung<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ekiwi.de\/index.php\/198\/php-debugging-in-xampp-und-uestudio-einrichten\/#Update_Xdebug_ab_Version_3\" >Update: Xdebug ab Version 3<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ekiwi.de\/index.php\/198\/php-debugging-in-xampp-und-uestudio-einrichten\/#Debugging_mit_Visual_Studio_Code\" >Debugging mit Visual Studio Code<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ekiwi.de\/index.php\/198\/php-debugging-in-xampp-und-uestudio-einrichten\/#Debugging_mit_UEStudio\" >Debugging mit UEStudio<\/a><\/li><\/ul><\/nav><\/div>\n<p><a href=\"https:\/\/www.apachefriends.org\/de\/index.html\" rel=\"noopener\" target=\"_blank\">XAMPP<\/a> ist eine recht einfache M\u00f6glichkeit einen Apache-Server als Entwicklungsumgebung mit PHP unter Windows einzurichten. Leider fehlt standardm\u00e4\u00dfig die M\u00f6glichkeit zu debuggen. Hierf\u00fcr muss <code>XDebug<\/code> installiert werden. Dies ist aber recht einfach m\u00f6glich.<\/p>\n<p><!--more--><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Video_Anleitung\"><\/span>Video Anleitung<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><iframe loading=\"lazy\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/ExddjAcvEG0\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Anleitung\"><\/span>Anleitung<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In dem Beispiel gehen wir davon aus, dass Xampp bereits installiert ist. F\u00fcr das Debugging muss das <code>XDebug<\/code> Modul eingerichtet werden. Schaut man auf der <a href=\"https:\/\/xdebug.org\/download.php\" target=\"_blank\" rel=\"noopener\">XDebug-Downloadseite<\/a> findet man jede Menge verschiedene Versionen. Letztendlich m\u00fcssen lokale PHP-Version, Compiler und XDebug-Version, 32bit oder 64bit zusammenpassen, sonst geht es nicht.<\/p>\n<p>Gl\u00fccklicherweise gibt es <a href=\"https:\/\/xdebug.org\/wizard.php\" rel=\"noopener\" target=\"_blank\">einen Wizard<\/a>, welcher uns die korrekte Version ermittelt und zum Download bereitstellt. In diesen kopiert man einfach den Inhalt seiner <code>phpinfo();<\/code> Ausgabe.<br \/>\nEinfach eine phpinfo-Seite im Browser aufrufen, alles markieren, kopieren und im Wizard einf\u00fcgen.<\/p>\n<p>Anschlie\u00dfend wird die passende Version angezeigt:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2018\/03\/debug_1.png\" alt=\"\" width=\"514\" height=\"551\" class=\"alignnone size-full wp-image-199\" srcset=\"\/wp-content\/uploads\/2018\/03\/debug_1.png 514w, \/wp-content\/uploads\/2018\/03\/debug_1-280x300.png 280w\" sizes=\"auto, (max-width: 514px) 100vw, 514px\" \/><\/p>\n<p>Passend zum Download werden auch gleich die Schritte zur Konfiguration angezeigt. D.h. Download durchf\u00fchren, in dem vorgeschlagenen Ordner abspeichern. Anschlie\u00dfend bearbeiten wir noch die <code>php.ini<\/code> Datei. Auch hier wird ja passenderweise gleich der richtige Pfad angezeigt.<\/p>\n<p>In der <code>php.ini<\/code> Datei sind allerdings noch ein paar mehr Eingaben notwendig, damit es l\u00e4uft:<\/p>\n<pre>\r\n[xdebug]\r\nxdebug.remote_enable=1\r\nxdebug.remote_host=localhost\r\nxdebug.remote_port=9000\r\nxdebug.remote_handler=\"dbgp\"\r\nxdebug.remote_mode=req\r\nxdebug.profiler_enable = 1\r\nxdebug.profiler_output_dir = \"c:\/temp\"\r\nxdebug.collect_params = 4\r\nxdebug.collect_return = on\r\nxdebug.collect_vars = on\t\r\nxdebug.show_local_vars = 1\r\n\r\nzend_extension = C:\\xampp\\php\\ext\\php_xdebug.dll<\/pre>\n<p>Anschlie\u00dfend wird der Server \u00fcber die Konsole neu gestartet. Der Debug-Modus sollte nun laufen.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Update_Xdebug_ab_Version_3\"><\/span>Update: Xdebug ab Version 3<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Ab Version 3 von Xdebug lauten die Zeilen f\u00fcr die Konfiguration so:<\/p>\n<pre>\r\nxdebug.mode=debug\r\nxdebug.client_host=127.0.0.1\r\nxdebug.client_port=9000\r\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Debugging_mit_Visual_Studio_Code\"><\/span>Debugging mit Visual Studio Code<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><iframe loading=\"lazy\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/lZHNADo-WNA\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>F\u00fcr Visual Studio Code gibt es ein passendes Plugin f\u00fcr das Debugging:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2018\/03\/code_debug_1.jpg\" alt=\"\" width=\"700\" height=\"474\" class=\"alignnone size-full wp-image-209\" srcset=\"\/wp-content\/uploads\/2018\/03\/code_debug_1.jpg 700w, \/wp-content\/uploads\/2018\/03\/code_debug_1-300x203.jpg 300w, \/wp-content\/uploads\/2018\/03\/code_debug_1-120x80.jpg 120w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>Das Plugin bzw. die Extension kann direkt in Visual Studio Code installiert werden. In der PHP-Datei setzt man nun die gew\u00fcnschten Breakpoints. Dies geht einfach \u00fcber die Taste F9. Anschlie\u00dfend wird das Debugging \u00fcber das Men\u00fc gestartet:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2018\/03\/code_debug_2.png\" alt=\"\" width=\"660\" height=\"504\" class=\"alignnone size-full wp-image-206\" srcset=\"\/wp-content\/uploads\/2018\/03\/code_debug_2.png 660w, \/wp-content\/uploads\/2018\/03\/code_debug_2-300x229.png 300w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/><\/p>\n<p>Als Debugging-Typ w\u00e4hlt man konsequenterweise PHP aus.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2018\/03\/code_debug_3.png\" alt=\"\" width=\"413\" height=\"174\" class=\"alignnone size-full wp-image-207\" srcset=\"\/wp-content\/uploads\/2018\/03\/code_debug_3.png 413w, \/wp-content\/uploads\/2018\/03\/code_debug_3-300x126.png 300w\" sizes=\"auto, (max-width: 413px) 100vw, 413px\" \/><\/p>\n<p>Anschlie\u00dfend ruft man im Browser das zu debuggende Script auf. Hierzu muss am Ende der Parameter <code>?XDEBUG_SESSION_START=myPHPTest<\/code> angef\u00fcgt werden. <\/p>\n<p>Ist alles korrekt konfiguriert, h\u00e4lt das Script an den definierten Brechpunkten an und das Debugging kann starten.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2018\/03\/code_debug_4.png\" alt=\"\" width=\"764\" height=\"254\" class=\"alignnone size-full wp-image-208\" srcset=\"\/wp-content\/uploads\/2018\/03\/code_debug_4.png 764w, \/wp-content\/uploads\/2018\/03\/code_debug_4-300x100.png 300w\" sizes=\"auto, (max-width: 764px) 100vw, 764px\" \/><\/p>\n<hr>\n<h2><span class=\"ez-toc-section\" id=\"Debugging_mit_UEStudio\"><\/span>Debugging mit UEStudio<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Um den in den Genuss des Debuggings zu kommen, ben\u00f6tigt man nun noch eine passende IDE bzw. Client. In meinem Fall verwende ich die Software <a href=\"https:\/\/www.ultraedit.com\/products\/uestudio\/\" rel=\"noopener\" target=\"_blank\">UEStudio<\/a>.<\/p>\n<p>Um das Debugging in UEStudio zu nutzen, muss man ein Projekt anlegen:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2018\/03\/debug_2.png\" alt=\"\" width=\"439\" height=\"176\" class=\"alignnone size-full wp-image-200\" srcset=\"\/wp-content\/uploads\/2018\/03\/debug_2.png 439w, \/wp-content\/uploads\/2018\/03\/debug_2-300x120.png 300w\" sizes=\"auto, (max-width: 439px) 100vw, 439px\" \/><\/p>\n<p>In den Projekteinstellungen muss nun noch der Debugger auf XDebug eingestellt werden:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2018\/03\/debug_3.png\" alt=\"\" width=\"458\" height=\"455\" class=\"alignnone size-full wp-image-201\" srcset=\"\/wp-content\/uploads\/2018\/03\/debug_3.png 458w, \/wp-content\/uploads\/2018\/03\/debug_3-150x150.png 150w, \/wp-content\/uploads\/2018\/03\/debug_3-300x298.png 300w\" sizes=\"auto, (max-width: 458px) 100vw, 458px\" \/><\/p>\n<p>Um das Debugging zu starten, klickt man im &#8222;Build&#8220; Men\u00fc auf den Button:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2018\/03\/debug_4.png\" alt=\"\" width=\"178\" height=\"140\" class=\"alignnone size-full wp-image-202\" \/><\/p>\n<p>Im Ausgabe-Fenster sollte ein Hinweis erscheinen, dass auf eingehende Debug-Verbindungen gewartet wird:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2018\/03\/debug_5.png\" alt=\"\" width=\"225\" height=\"103\" class=\"alignnone size-full wp-image-203\" \/><\/p>\n<p>Im Browser k\u00f6nnen wir jetzt die PHP-Datei aufrufen und das Debugging starten. Hierzu muss am Ende der Parameter <code>?XDEBUG_SESSION_START=myPHPTest<\/code> angef\u00fcgt werden. Z.B.:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2018\/03\/debug_6.png\" alt=\"\" width=\"395\" height=\"35\" class=\"alignnone size-full wp-image-204\" srcset=\"\/wp-content\/uploads\/2018\/03\/debug_6.png 395w, \/wp-content\/uploads\/2018\/03\/debug_6-300x27.png 300w\" sizes=\"auto, (max-width: 395px) 100vw, 395px\" \/><\/p>\n<p>Wenn alles richtig konfiguriert ist, aktiviert sich in UEStudio das Debugging und beim ersten Breakpoint sollte die Ausf\u00fchrung anhalten.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2018\/03\/debug_7.png\" alt=\"\" width=\"700\" height=\"359\" class=\"alignnone size-full wp-image-205\" srcset=\"\/wp-content\/uploads\/2018\/03\/debug_7.png 700w, \/wp-content\/uploads\/2018\/03\/debug_7-300x154.png 300w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>\u00dcber das Debug-Men\u00fc kann man nun die Ausf\u00fchrung steuern, Variablen \u00fcberwachen etc.<\/p>","protected":false},"excerpt":{"rendered":"<p>XAMPP ist eine recht einfache M\u00f6glichkeit einen Apache-Server als Entwicklungsumgebung mit PHP unter Windows einzurichten. Leider fehlt standardm\u00e4\u00dfig die M\u00f6glichkeit<\/p>\n","protected":false},"author":1,"featured_media":210,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[14],"tags":[40,31,42,41],"class_list":["post-198","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-debugging","tag-php","tag-uestudio","tag-visual-studio-code"],"_links":{"self":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/posts\/198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/comments?post=198"}],"version-history":[{"count":0,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/posts\/198\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/media\/210"}],"wp:attachment":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/media?parent=198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/categories?post=198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/tags?post=198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}