Published vendor packages have invalid path

Hello,

I am using Bedrock with Sage and Acorn 5.0.5. PHP version is 8.3 and WordPress is 6.8.3

I am using a Laravel package log-viewer. When I publish it’s assets using wp acorn vendor:publish --tag=log-viewer-assets --force and. the log-viewer, then it says that asset files are not found.

I discovered that the command stores files in public/vendor/log-viewer folder, but it looks for them in the actual log-viewer page in public/build/vendor/log-viewer folder.

In my log-viewer config file, my assets path is vendor/log-viewer. When I try to add build/, then it starts looking for them in public/build/build/vendor/log-viewer folder.

I am posting this one in here, since my Laravel framework apps do not have this issue. They work fine without any issues and I am using the very same package, log-viewer.

Any ideas what may be causing this issue?

I guess you’ve already tried running wp acorn optimize:clear? I wrote an article about implementing the log-viewer; sorry, it’s in French, but you can easily translate it.

https://medium.com/@bantunes/comment-implémenter-log-viewer-dans-une-stack-laravel-wordpress-bedrock-acorn-a05a01a07f97

Cache is cleared and it still does not work. It does not seem to be log-viewer package issue. I have successfully installed it on actual Laravel apps and no problem.

Then you should write it on your own, here’s what I made

config/log-viewer.php

<?php

use Opcodes\LogViewer\Http\Middleware\AuthorizeLogViewer;

return [
    'enabled' => env('LOG_VIEWER_ENABLED', true),
    'route_path' => env('LOG_VIEWER_ROUTE_PATH', 'logs'),
    'assets_path' => env('LOG_VIEWER_ASSETS_PATH', 'content/vendor/log-viewer'),

    'middleware' => [
        'web',
        'wp.auth',
        'wp.admin',
        AuthorizeLogViewer::class,
    ],

    'api_middleware' => [
        'wp.auth',
        'wp.admin',
        AuthorizeLogViewer::class,
    ],

    'include_files' => [
        'scheduler.log',
        '*.log',
        '**/*.log',
    ],

    // Important pour afficher aussi les logs non-Laravel (ex: scheduler.log)
    'hide_unknown_files' => false,
];

and the middleware if you need inspiration:

<?php

namespace Opcodes\LogViewer\Http\Middleware;

use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Gate;
use Opcodes\LogViewer\Facades\LogViewer;

class AuthorizeLogViewer
{
    public function handle($request, $next)
    {
        if (
            config('log-viewer.require_auth_in_production', false)
            && App::isProduction()
            && ! Gate::has('viewLogViewer')
            && ! LogViewer::hasAuthCallback()
        ) {
            abort(403);
        }

        LogViewer::auth();

        return $next($request);
    }
}

I instead made a copy of vendor files. Using this command: wp acorn vendor:publish --tag=log-viewer-assets --force && cd public && cp -R vendor build/vendor. This resolved my issue. Changing assets path does not work. I have my path set to vendor/log-viewer and it looks it in public/build/vendor/log-viewer/app.css. If I dont copy them over, then it alerts me that it couldn’t find app.css file.

Maybe it will be fixed with Acron v6 and Laravel 13.