Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spatie Ignition for Debugging #256

Merged
merged 11 commits into from
Dec 5, 2024
Merged

Spatie Ignition for Debugging #256

merged 11 commits into from
Dec 5, 2024

Conversation

darylldoyle
Copy link
Collaborator

@darylldoyle darylldoyle commented Nov 28, 2024

Description of the Change

This PR adds a new plugin to the scaffold. The plugin adds spatie/ignition as a debugging tool. Ignition is the default error page for Laravel Projects, and for good reason. It includes great stack traces as well as other helpful information that can be used to debug the issue. There's an example of an issue page below:
wp-scaffold test_

It lets engineers quickly jump to the problem code, reducing debugging time (see video below).

Tower.-.wp-scaffold.2024-11-28.at.12.33.01.PM.1.mp4

We load it using the 000-wp-ignition-loader.php file as it needs to run as soon as possible in order to catch errors in MU plugins.

Whilst this should be ignored from deployments to production environments, since we should be handling errors transparently there, it does have some protections in place to ensure it doesn't run, as long as the wp_get_environment_type() returns correctly.

Note

This update doesn't handle Fatal Errors, like Abstract Class extension issues because they happen at compile-time and therefore are handled by PHP's and WordPress's register_shutdown_function() before this package has time to process them.

How to test the Change

Clone locally. Change something in the plugins/theme to cause a PHP error. See Ignition.

Changelog Entry

  • Added - Ignition as an error page.

Credits

Props @darylldoyle

Checklist:

@darylldoyle darylldoyle self-assigned this Nov 28, 2024
Copy link
Member

@tobeycodes tobeycodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this! I left my thoughts/questions in some comments but not blocking from moving forward

mu-plugins/wp-ignition/wp-ignition.php Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: why not include this is a dev dependency in the root composer.json so it's one less composer.json file. When running --production it won't be loaded and then the plugin code would never run

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I played with that idea a bunch. Unfortunately we'd need to load our autoloader in WP-config.php or something, otherwise it doesn't load early enough.

Our current MU plugin loads the autoloader late in the WP boot process and we want it to load as the first plugin, to ensure all errors are handled by Ignition

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think wp-config.php is the best place to load this to be honest. The repo could have a wp-config-sample.php

mu-plugins/000-wp-ignition-loader.php Outdated Show resolved Hide resolved
@darylldoyle darylldoyle mentioned this pull request Dec 3, 2024
4 tasks
@darylldoyle darylldoyle changed the title Add new Ignition plugin Spatie Ignition for Debugging Dec 5, 2024
@darylldoyle darylldoyle merged commit f98306f into trunk Dec 5, 2024
7 checks passed
@darylldoyle darylldoyle deleted the feature/ignition branch December 5, 2024 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants