Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Scope Exit Laravel Package

phplang/scope-exit

Tiny PHP helper that emulates “defer”/scope-exit behavior: register callbacks to run automatically when a block/function ends, ensuring reliable cleanup (close files, unlock mutexes, rollback temp state) even if exceptions occur.

View on GitHub
Deep Wiki
Context7

ScopeExit

This simple class provides an implementation of C++'s SCOPE_EXIT, or GoLang's defer.

To use, assign an instance of this object to a local variable. When that variable falls out of scope (or is explicitly unset), the callback passed to the constructor will be invoked. This is useful, for example, to aid cleanup at the end of a function.

function f(&$x) {
  $x = 1;
  $_ = new \PhpLang\ScopeExit(function() use (&$x) { $x = 2; });
  // $x is still 1 at this point.
  return 42;
  // After the return, the local scope is cleaned up, the closure is invoked, and it's set to 2
}

f($a);
var_dump($a); // int(2)
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport