This course is archived!
This tutorial is built using Drupal 8.0. The fundamental concepts of Drupal 8 - like services & routing - are still valid, but newer versions of Drupal *do* have major differences.
05.
Debugging!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
17 Comments
You can enable debugging in D8 by running the command drupal site:mode dev with DrupalConsole.
Thanks
Yea there is obviously some weirdness for some machines related to entering the debug mode. This is an excellent alternative (and really easier anyways).
As noted on previous chapters, if you are running this course on Drupal 9, at time of writing Drupal Console is not compatible with D9.
And Drush does not give helpful debugging information for routes, unfortunately.
Next best thing is to use the Devel module.
composer require drupal/develThen install the Devel module at
admin/modules.Then clear cache and browse to
devel/routes.You can see all the routes listed. If you press the 'Devel' button at the end of each row, you get all the extended debugging information for that route, but not nicely formatted like in Drupal Console, instead it looks like a
var_dumpof some kind.Hey Griff P.
Thank you very much for you notes, it's very helpful! Unfortunately we can't update our course to be compatible with Drupal 9 right now but you notes can help many users so thank you again for sharing it!
Cheers!
Glad to hear it! I use bash and autocompletion (in general) works fine - I haven't hooked up the Drupal Console's auto-completion, however, but I imagine it would work fine (I use autocompletion for Symfony's console, which is accomplished in a similar way).
On Drupal 8.3.5. I ran into problems running drupal router:debug views_ui.form_display and ended up have to set back symfony/yaml to 2.8.6
$composer -v require symfony/yaml:2.8.6
Now it works!
$ drupal router:debug views_ui.form_display
Route views_ui.form_display
Path /admin/structure/views/{js}/display/{view}/{display_id}/{type}
Defaults
_controller \Drupal\views_ui\Form\Ajax\Display::getForm
Options
compiler_class \Drupal\Core\Routing\RouteCompiler
parameters view:
tempstore: true
type: 'entity:view'
converter: drupal.proxy_original_service.paramconverter.views_ui
_admin_route 1
_route_filters method_filter
content_type_header_matcher
_route_enhancers route_enhancer.param_conversion
_access_checks access_check.entity
Hey Allison R. ,
Thank you for sharing it! What was the problem if you don't mind to say? I wonder what version of symfony/yaml was installed before you downgrade to v2.8.6.
Cheers!
The problem was:
$ drupal router:debug views_ui.form_display
PHP Fatal error: Call to undefined method Symfony\Component\Yaml\Inline::isHash() in public_html/d8-underthehood/vendor/symfony/yaml/Dumper.php on line 61
PHP Stack trace:
PHP 1. {main}() /usr/local/bin/drupal:0
PHP 2. require() /usr/local/bin/drupal:10
PHP 3. require() phar:///usr/local/bin/drupal/bin/drupal:3
PHP 4. Symfony\Component\Console\Application->run($input = *uninitialized*, $output = *uninitialized*) phar:///usr/local/bin/drupal/bin/drupal.php:115
PHP 5. Drupal\Console\Application->doRun($input = class Symfony\Component\Console\Input\ArgvInput { private $tokens = array (0 => 'router:debug',
$ composer show | grep symfony/
symfony/yaml v2.8.18 Symfony Yaml Component
$php -v
PHP 5.6.23
Of course I ran in to other issues later on. Don't mess with versions!!! Haha!
It appears console broke -- with the error:
Console is not installed at:____ You must execute the following composer commands: ____
:(
As per debug suggestions I had to remove:
composer remove symfony/finder v3.3.4
composer remove symfony/filesystem v3.3.4
Then I could run:
composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader
:)
This still works:
drupal router:debug views_ui.form_display
------------------------------
Bottom line
------------------------------
$ composer show | grep symfony/
symfony/browser-kit v2.8.24 Symfony BrowserKit Component
symfony/class-loader v2.8.24 Symfony ClassLoader Component
symfony/config v2.8.24 Symfony Config Component
symfony/console v2.8.24 Symfony Console Component
symfony/css-selector v2.8.24 Symfony CssSelector Component
symfony/debug v2.8.24 Symfony Debug Component
symfony/dependency-injection v2.8.24 Symfony DependencyInjection Component
symfony/dom-crawler v2.8.11 Symfony DomCrawler Component
symfony/event-dispatcher v2.8.24 Symfony EventDispatcher Component
symfony/expression-language v2.8.24 Symfony ExpressionLanguage Component
symfony/filesystem v2.8.24 Symfony Filesystem Component
symfony/finder v2.8.24 Symfony Finder Component
symfony/http-foundation v2.8.24 Symfony HttpFoundation Component
symfony/http-kernel v2.8.24 Symfony HttpKernel Component
symfony/polyfill-apcu v1.4.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-iconv v1.4.0 Symfony polyfill for the Iconv extension
symfony/polyfill-mbstring v1.4.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php54 v1.4.0 Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions
symfony/polyfill-php55 v1.4.0 Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions
symfony/process v2.8.24 Symfony Process Component
symfony/psr-http-message-bridge v1.0.0 PSR HTTP message bridge
symfony/routing v2.8.24 Symfony Routing Component
symfony/serializer v2.8.24 Symfony Serializer Component
symfony/translation v2.8.24 Symfony Translation Component
symfony/validator v2.8.24 Symfony Validator Component
symfony/var-dumper v3.3.4 Symfony mechanism for exploring and dumping PHP variables
symfony/yaml v2.8.6 Symfony Yaml Component
Hey Allison R. ,
Thanks a lot for sharing it! I think it could be useful for other users.
Cheers!
Hi, I followed all the steps here, but when I uncomment the lines in settings.php, to include settings.local.php, I get a "Class 'Drupal\Component\Assertion\Handle' not found". I'm using drupal 8.0.0. Any suggestion?
Hmm, I don't get this with a fresh 8.0.0. install (downloaded from drupal.org/8). This line *does* come from settings.local.php (you'll find mention of this class there), but the class itself is located in core/lib/Drupal/Component/Assertion/Handle.php and should be autoloaded just like everything else. So I'm not so sure about this. Does this information give you any clues?
If I comment out that line, drupal cache:rebuild complains about DRUPAL_ROOT not defined. I think this can be related to my PHP version (that's 5.5.29, on a MAC with El Capitan, installed with brew) but other than that, I don't know where else to dig...
Same problem. What is your PHP version?
Mine is 5.5.29.
I would try using DrupalConsole to enter debugging mode instead - https://knpuniversity.com/s.... For some reason, some people are having strange issues after entering debugging mode by including settings.local.php. But I haven't been able to repeat that yet :)
"Houston: no signs of life"
Start the conversation!