beaudierman's avatar

Horizon Asset Path Help

Hello,

I'm trying to get Laravel Horizon set up, but when I run the php artisan horizon:publish command, it places the assets in the public/vendor directory. This is a problem for us because our site already has a page that displays at /vendor. Due to this, I've always had to place our vendor assets in public/assets/vendor.

I ran into a similar problem when installing Laravel Nova, but I was able to fix the problem by overriding the Nova layout.blade.php file and updating the mix path... but if I do this with Horizon it throws an error saying:

Horizon assets are not published. Please run: php artisan horizon:publish

Which is caused by the Horizon::assetsAreCurrent() function being called by the Horizon HomeController. Does anyone know of a way to accomplish this without forking the entire repo just to make this one change?

0 likes
2 replies
syofyanzuhad's avatar

i had the same problem but fiexed it in unusual way. I just add it on vendor controller on vendor/laravel/horizon/src/Http/Controllers/HomeController.php and remove it after the error is gone...

<?php

namespace Laravel\Horizon\Http\Controllers;

use Illuminate\Support\Facades\App;

class HomeController extends Controller
{
    /**
     * Single page application catch-all route.
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
        return view('horizon::layout', [
//          'assetsAreCurrent' => true,
            'isDownForMaintenance' => App::isDownForMaintenance(),
        ]);
    }
}
itwasntme's avatar

The only right solution here is to follow the instructions.

Laravel Horzion no longer needs to publish assets, so the right solution is, to delete the horizon assets in ./public/vendor/

Please or to participate in this conversation.