Back to overview

Pausing and disabling Ray execution

26 April 2024

Image of Zuzana

Zuzana

Let's say you have multiple Ray calls that you need to temporarily disable. You could go and comment them all out, or you could use ray()->disable() at the top of the file (or higher up in the call stack) to temporarily disable Ray execution.

You can also check if Ray has already been disabled somewhere else in your application by running ray()->disabled(), and you can run ray()->enable() and ray()->enabled() too.

Disabling and enabling Ray execution is especially useful when running tests. You don't want your Ray output to be cluttered by Ray calls when running tests, which might happen if you have Ray calls scattered throughout your application.

An easy way to deal with this situation is to disable Ray at the beginning of the test and only enable it during the arrange step of the test. You can learn more about this technique in this blog post.

What if you want to halt code execution altogether? There is a method for that! Run ray()->pause() to pause ALL code execution, and when you are ready to move forward, you can simply press the Continue button in the output.

Stay in the loop with updates & promotions for Ray

We only send a few emails a year.

Debug without breaking your flow

Ray keeps all your debug output neatly organized in a dedicated desktop app.

Licenses are valid for 1 year and managed through Spatie. Licenses purchased before Ray 3 remain valid. VAT is calculated at checkout.