{"id":319,"date":"2020-05-26T00:56:17","date_gmt":"2020-05-25T22:56:17","guid":{"rendered":"http:\/\/xpam.pl\/blog\/?p=319"},"modified":"2024-04-03T01:44:34","modified_gmt":"2024-04-02T23:44:34","slug":"debugging-laravel-in-eclipse-pdt","status":"publish","type":"post","link":"https:\/\/xpam.pl\/blog\/?p=319","title":{"rendered":"Debugging Laravel in Eclipse PDT"},"content":{"rendered":"<p>I don't use PHP enough to justify buying a PHPStorm license so I am using Eclipse PDT instead. I am a bit rusty with Eclipse and PHP so I couldn't really find anything on Google about debugging Laravel projects in Eclipse. Finally figured it out, here is how.<\/p>\n<p>Examples are done on <strong>Eclipse IDE Version: 2019-12 (4.14.0)<\/strong>.<\/p>\n<p>First, configure <a href=\"https:\/\/wiki.eclipse.org\/Debugging_using_XDebug\">XDebug with Eclipse<\/a>. On Fedora you can install it via<br \/>\n<code>sudo dnf install php-xdebug<\/code><br \/>\nCheck that XDebug remote is enabled with <code>phpinfo()<\/code> test site, if not add the following line to your php.ini:<br \/>\n<code>xdebug.remote_enable = 1<\/code><br \/>\nNow in Eclipse, we first add a server. In <code>Window -&gt; Preferences -&gt; PHP -&gt; Servers<\/code> add a new server like this:<\/p>\n<p><a href=\"https:\/\/xpam.pl\/blog\/wp-content\/uploads\/2020\/05\/php_ide_1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-320 size-full\" src=\"https:\/\/xpam.pl\/blog\/wp-content\/uploads\/2020\/05\/php_ide_1.png\" alt=\"\" width=\"605\" height=\"212\" \/><\/a><\/p>\n<p>Document root is our Laravel public folder and base URL is the default host and port of<br \/>\n<code>php artisan serve<\/code><br \/>\nNow check your Debug settings in <code>PHP -&gt; Debug<\/code>, select the newly created server and check that XDebug is set as the debugger:<\/p>\n<p><a href=\"https:\/\/xpam.pl\/blog\/wp-content\/uploads\/2020\/05\/php_ide_2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-321 size-full\" src=\"https:\/\/xpam.pl\/blog\/wp-content\/uploads\/2020\/05\/php_ide_2.png\" alt=\"\" width=\"954\" height=\"208\" \/><\/a><\/p>\n<p>If XDebug is not present here, configure it under <code>PHP -&gt; Debug -&gt; Debuggers<\/code> first.<\/p>\n<p>Finally, under <code>General -&gt; Web Browser<\/code>, we select an external web browser to launch our website instead of integrated Eclipse Browser.<\/p>\n<p><a href=\"https:\/\/xpam.pl\/blog\/wp-content\/uploads\/2020\/05\/php_ide_3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-322 size-full\" src=\"https:\/\/xpam.pl\/blog\/wp-content\/uploads\/2020\/05\/php_ide_3.png\" alt=\"\" width=\"988\" height=\"337\" \/><\/a><\/p>\n<p>We are done with Preferences so close it. Next to the Debug button in main Eclipse toolbar, click on the arrow for the dropdown and select <strong>Debug configurations&#8230;<\/strong><\/p>\n<p>Create a new <strong>PHP Web Application<\/strong> config like this.<\/p>\n<p><a href=\"https:\/\/xpam.pl\/blog\/wp-content\/uploads\/2020\/05\/php_ide_4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-323 size-full\" src=\"https:\/\/xpam.pl\/blog\/wp-content\/uploads\/2020\/05\/php_ide_4.png\" alt=\"\" width=\"1062\" height=\"569\" \/><\/a><\/p>\n<p>We point the file to public index and map it to root URL (default by <code>artisan serve<\/code>). Under Debugger tab check that XDebug is selected.<\/p>\n<p>Now go to the terminal and serve your laravel app as you would with<br \/>\n<code>php artisan serve<\/code><br \/>\nFinally, run the \"web\" Debug configuration from Eclipse. Eclipse should go into the Debug mode and open up your site in your selected browser. You can now place your breakpoints in controllers or wherever and things just work like you would expect.<\/p>\n<div class=\"wp-post-signature\">\r\n<br \/>\r\n<br \/>\r\n<img src='https:\/\/xpam.pl\/aaaaff.png' title='Moonie' \/> Cen<br \/>\r\n<a href='https:\/\/github.com\/cen1'>GitHub<\/a><br \/>\r\n<a href='https:\/\/eurobattle.net'>Eurobattle.net<\/a><br \/>\r\n<a href='https:\/\/lagabuse.com'>Lagabuse.com<\/a><br \/>\r\n<a href='https:\/\/bnetdocs.org'>Bnetdocs<\/a><br \/>\r\n<\/div>\r\n","protected":false},"excerpt":{"rendered":"<p>I don't use PHP enough to justify buying a PHPStorm license so I am using Eclipse PDT instead. I am a bit rusty with Eclipse and PHP so I couldn't really find anything on Google about debugging Laravel projects in Eclipse. Finally figured it out, here is how. Examples are done on Eclipse IDE Version: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31,3],"tags":[],"class_list":["post-319","post","type-post","status-publish","format-standard","hentry","category-php","category-programming"],"_links":{"self":[{"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/posts\/319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=319"}],"version-history":[{"count":6,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/posts\/319\/revisions"}],"predecessor-version":[{"id":562,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=\/wp\/v2\/posts\/319\/revisions\/562"}],"wp:attachment":[{"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xpam.pl\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}