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: 2019-12 (4.14.0).
First, configure XDebug with Eclipse. On Fedora you can install it via
sudo dnf install php-xdebug
Check that XDebug remote is enabled with phpinfo()
test site, if not add the following line to your php.ini:
xdebug.remote_enable = 1
Now in Eclipse, we first add a server. In Window -> Preferences -> PHP -> Servers
add a new server like this:
Document root is our Laravel public folder and base URL is the default host and port of
php artisan serve
Now check your Debug settings in PHP -> Debug
, select the newly created server and check that XDebug is set as the debugger:
If XDebug is not present here, configure it under PHP -> Debug -> Debuggers
first.
Finally, under General -> Web Browser
, we select an external web browser to launch our website instead of integrated Eclipse Browser.
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 Debug configurations…
Create a new PHP Web Application config like this.
We point the file to public index and map it to root URL (default by artisan serve
). Under Debugger tab check that XDebug is selected.
Now go to the terminal and serve your laravel app as you would with
php artisan serve
Finally, 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.