2

I have a breakpoint function I use for debugging in all my php development projects and which I want to use with Magento 2. It's a simple function and the details of it are irrelevant - it basically receives a variable as input and outputs the content of the variable in a nicely formatted way.

I'd like to include this as a 'global' function that I can call from any php or phtml file.

All the solutions I've found so far are either old (or at least pre magento 2) and don't seem to work, or they involve several files in several directories, registering modules etc. etc...

I'm not looking for other debugging methods, I'm sure M2 has loads of wonderfully complex and arcane ways to do this simple thing. The question is just about including a global function.

3

This can achieve this by Helper. You can create helper class & placed your global function into class.

$helper = $this->helper('<Extension_name>\<module_name>\Helper\Data');
$getreturn = $helper->yourFuntion(); 
2

Undoubtedly the 'wrong' way to do this but it seems to work if I add the function to /app/bootstrap.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.