roots / acorn

Laravel components for WordPress plugins and themes
https://roots.io/acorn/
MIT License
824 stars 94 forks source link

Livewire does not boot Blade directive #391

Closed caseymilne closed 3 months ago

caseymilne commented 3 months ago

Version

4.3

What did you expect to happen?

Expected @livewireStyles and @livewireAssets to be parsed when following the tutorial on Livewire integration, using:

<?php 

use Illuminate\Support\Facades\Blade;

add_filter('wp_head', function () {
    echo Blade::render('@livewireStyles');
});

add_filter('wp_footer', function () {
    echo Blade::render('@livewireScripts');
});

What actually happens?

@livewireStyles and @livewireAssets are printed as text to the screen. Debug shows that the Livewire boot never happens and the Blade directive is never set.

Steps to reproduce

Install Acorn. Add Livewire following the tutorial at https://roots.io/acorn/docs/using-livewire-with-wordpress/.

In my case, it works fine locally. The failure happens after deploying to the server (BlueHost). Perhaps it is a missing server requirement. I have tried with about 6 sites. It always works locally. It sometimes works on the server. I haven't been able to identify any real differences between the sites where it magically works versus one where it does not.

I thought it would be a cache issue, but after clearing caches a lot nothing changes. At one point I put error_log() into Livewire facade and boot files, they were never called. I deleted the entire Livewire /Mechanisms directory, and this did not throw an error.

ChatGPT says we have to register the Livewire service provider to ensure it loads. But this isn't mentioned in the Acorn docs, and doesn't usually seem required.

System info

Windows 11.

Log output

Unfortunately no error output for this.

Please confirm this isn't a support request.

Yes

Log1x commented 3 months ago

It sounds like your Providers may be cached on production and you need to either delete Acorn's cache folder manually or run wp acorn optimize:clear.

If you need more help, feel free to make a thread on Discourse.