I want to write a function that does some dirty work logging a transaction, but the anonymous function scope does not seem to register the parent scope $db and
$db
Use the use keyword to bind variables into the function's scope.
use
function() use ($db) {
Closures may also inherit variables from the parent scope. Any such variables must be declared in the function header [using use]. http://www.php.net/manual/en/functions.anonymous.php
Closures may also inherit variables from the parent scope. Any such variables must be declared in the function header [using use].
http://www.php.net/manual/en/functions.anonymous.php