development environment but gaining speed with Xdebug 3.x, PHP 7.x & 8.x and much more predictable & streamlined development environment. With DDEV/containers, setting-up Xdebug has become a breeze.
Earth about 480 million years ago • so… • bugs have been there all the time before computers • and annoyed engineers • fun fact: bed bugs are the horror of all pilgrims
my inventions] is an intuition, and comes with a burst, then difficulties arise – this thing gives out and [it is] then that ‘Bugs’ – as such little faults and difficulties are called – show themselves […].“ Thomas Edison, 1878
Laboratory • Operators traced an error in the Mark II to a moth trapped in a relay, coining the term bug. • This bug was carefully removed and taped to the log book. • source: Wikipedia
print_r($array); • die("I'm here"); Not in Live mode • debug::show(...); • debug::message(...); Also in Live mode • debug::dump(...); In Templates • $Foo.Debug()
CMS • ?isDev=1 Put the site into development mode, enabling debugging messages to the browser on a live server. For security, you'll be asked to log in with an administrator log-in. Will persist for the current browser session. • ?isTest=1 See above. • ?debug=1 Show a collection of debugging information about the director / controller operation • ?debug_request=1 Show all steps of the request from initial HTTPRequest to Controller to Template Rendering
executed • ?showtemplate=1 Show the compiled version of all the templates used, including line numbers. Good when you have a syntax error in a template. Cannot be used on a Live site without isDev when logged in as Admin. https://docs.silverstripe.org/en/5/developer_guides/debugging/ https://docs.silverstripe.org/en/5/developer_guides/debugging/url_variable_tools/
running queries System logs and messages Shows anything processed by a logger -> no need to check log Session Cookies Parameter Requirements Middleware Template SiteConfig Config System Cache Mails Headers CMS & PHP Version, Time & Memory Usage
has everything you need and a lot extensions for special requirements • apache-fpm/nginx • mariadb • all major PHP-Versions • project-type=silverstripe (thanks to firesphere) • plugins for PHPStorm and VSCode • See https://ddev.com/
• know the tools for craftsmanship 🛠 • no debugging information gets committed to git • easy setup with ddev and PHPStorm / VScode • actually it works out of the box 🦾 • ddev xdebug on/off ◦ switch it off for a faster dev experience when not debugging • you’ll become more sexy ❤
written by Derick Rethans - he works on it since 2002! • It uses the DBGp debugging protocol • It is a powerful tool for debugging and profiling PHP code.
setup much easier! Tweak a few things in your boilerplate, to make it always available. https://github.com/lerni/ootstra/tree/master/.vscode VSCode Extensions → .vscode/extensions.json • DDEV Manager - mainly automatic ‘ddev xdebug true/false’ • PHP Debug Adapter .vscode/tasks.json & .vscode/launch.json • "hostname": "0.0.0.0" for CLI debugging • "pathMappings": {“/var/www/html": "${workspaceFolder}"}
that are not easy to reach on the site ◦ e.g. shop checkout functionality • fixtures maybe a bit hard to setup • when a test works you’re done • best done via CLI
for bugs before they reach production • works better with well typed classes • forces you to think about types Cons: • Did I say it’s totally annoying… at least in the beginning
requirement • There’s a package to make PHPStan understand Silverstripe, e.g. DataObject::get() and its magic properties. composer require --dev syntro/silverstripe-phpstan ^5
REPL for SilverStripe running on Psy Shell 🚀 • PsySH is a runtime developer console, interactive debugger and REPL for PHP. • REPL = Read-eval-print loop You can • view classes/objects and static properties • run methods on objects • run sake commands and flush
in Silverstripe • The interactive debugger saves lives! Stop die()ing all the time. • an alternative for executing simple one time tasks More informations: • https://github.com/pstaender/ssshell • https://psysh.org/