Overriding e() (or any of the Laravel Helpers)

Posted 8 months ago by devonblzx

So, prior to 5.5, you could require a file at the top of bootstrap/autoload.php.

Now, I can't seem to find a way to override Laravel helper functions reliably:

  1. doesn't seem to work any longer.
  2. Composer autoloaded files load after the Laravel Helpers.
  3. Adding in public/index.php does not override Helpers for testing / console.

Does anyone have a reliable solution?

The Laravel escape function is lacking when it comes to protecting against Vue.js interpolation injections, so I'd like to implement my own solution to replace curly braces.

A temporary solution I've used is to set the Blade echo format to my own function that incorporates:

preg_replace('/({|}|{|}|{|})(?=\S)/', '$1 ', $value);

However, this is not full coverage since the echo format is not used everywhere.

Updated with regex solution

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.