question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mix() method not working in Blade templates

See original GitHub issue

Hello, I am on Laravel Framework version 5.3.28 and have installed Laravel Mix via NPM. Using the version() API option results in the following error in my blade template: Call to undefined function mix() (View: /var/www/html/servicedesk/resources/views/welcome.blade.php)

I am implementing in the following way, per docs:

<link rel="stylesheet" href="{{ mix('css/app.css') }}">
<script src="{{ mix('js/app.js') }}"></script>

How can I resolve this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

6reactions
7ammercommented, Apr 25, 2017

Try this:

function cache_buster($asset_url) {
  try {
    $file = file_get_contents(base_path() . "/public/mix-manifest.json");
  } catch (Exception $e){
    return url('/') . $asset_url;
  }

  $json = json_decode($file, true);

  foreach ($json as $key => $a) if($asset_url == $key) return url('/') . $a;

  return url('/') . $asset_url;
}
5reactions
Germeycommented, Jan 22, 2017

mix method will be supported since 5.4.x? How can I add it in 5.3.x?

Read more comments on GitHub >

github_iconTop Results From Across the Web

mix() method not working in Blade templates #47 - GitHub
Hello, I am on Laravel Framework version 5.3.28 and have installed Laravel Mix via NPM. Using the version() API option results in the ......
Read more >
Laravel Blade, Mix and SASS resource versioning sharing
Laravel Mix handles .blade and CSS/JS files differently. You won't get the same hash for your logo image as for .blade assets it...
Read more >
Blade Templates - The PHP Framework For Web Artisans
Blade is the simple, yet powerful templating engine that is included with Laravel. Unlike some PHP templating engines, Blade does not restrict you...
Read more >
Laravel Mix - JavaScript not working - Laracasts
I installed laravel mix with bootstrap, jquery and popper.js then run npm run dev and imported it in the blade template: Copy Code...
Read more >
4. Blade Templating - Laravel: Up & Running, 2nd Edition [Book]
Simply call Blade::component() on the Blade facade—the most common location is the boot() method of the AppServiceProvider —and pass it first the location...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found