Acorn component - Unable to locate a class or view for component

Hello everyone,
I’m facing an issue with Sage and Acorn where I’m unable to locate a class or view for a custom component I’ve created. I’m using Sage 10.5.1 with Laravel/Acorn 3.1.0 and have followed the instructions to create a new component.

Here’s what I’ve done so far:

  1. Created the component using the Acorn CLI command:
    wp acorn make:component LinkClickable
  2. The component class (LinkClickable.php) has been generated in the app/View/Components directory with the correct namespace: namespace App\View\Components;*
  3. The corresponding Blade view file is located at resources/views/components/link-clickable.blade.php.
  4. I’ve cleared the view cache using:
    wp acorn view:clear
  5. In my Blade template, I’m including the component like this:
    <x-LinkClickable link="{{ get_author_posts_url(get_current_user_id()) }}" class="nav-link" target='_blank'>{{ __('my reviews') }}</x-LinkClickable>

I’m using vagrant & ansible/trellis for local server & provisioning to remote server.

Locally all works fine.
When I do a deploy in my remote machine this error appears:


**Fatal error**: Uncaught Exception: Unable to locate a class or view for component [LinkClickable]. (View: /srv/www/my-site/releases/1680186655/web/app/themes/mp_che_test/resources/views/partials/archive-header.blade.php)

in **/srv/www/my-site/releases/1680186655/vendor/illuminate/view/Compilers/ComponentTagCompiler.php** on line **311**

Call stack:

1. `Illuminate\V\E\CompilerEngine::handleViewException()`

/srv/www/my-site/releases/1680186655/vendor/illuminate/view/Engines/PhpEngine.php:60

2. `Illuminate\V\E\PhpEngine::evaluatePath()`

/srv/www/my-site/releases/1680186655/vendor/illuminate/view/Engines/CompilerEngine.php:70

3. `Illuminate\V\E\CompilerEngine::get()`

/srv/www/my-site/releases/1680186655/vendor/illuminate/view/View.php:195

4. `Illuminate\View\View::getContents()`

/srv/www/my-site/releases/1680186655/vendor/illuminate/view/View.php:178

5. `Illuminate\View\View::renderContents()`

/srv/www/my-site/releases/1680186655/vendor/illuminate/view/View.php:147

6. `Illuminate\View\View::render()`

app/themes/mp_che_test/index.php:12

7. `include()`

wp-includes/template-loader.php:106

8. `require_once()`

wp-blog-header.php:19

9. `require()`

index.php:6

I created 5 components with command cli acorn but in production and staging server they don’t work.
So I try to edit my composer.json file adding this:


  "post-autoload-dump": [
    "Roots\\Acorn\\ComposerScripts::postAutoloadDump",
    "wp acorn cache:clear",
    "wp acorn optimize:clear",
    "wp acorn view:clear",
    "wp acorn config:clear"
  ],
  "extra": {
    "acorn": {
      "providers": [
        "App\\Providers\\AdvProvider",
        "App\\Providers\\AuthProvider",
        "App\\Providers\\AuthorProvider",
        "App\\Providers\\BrandProvider",
        "App\\Providers\\HomepageProvider",
        "App\\Providers\\NominationsProvider",
        "App\\Providers\\ProductProvider",
        "App\\Providers\\ProductTestProvider",
        "App\\Providers\\ReviewsProvider",
        "App\\Providers\\SearchProvider",
        "App\\Providers\\TaxonomiesProvider",
        "App\\Providers\\ThemeServiceProvider"
      ],
      "components": [
        "App\\View\\Components\\Alert",
        "App\\View\\Components\\RatingWrapper",
        "App\\View\\Components\\AdvBlock",
        "App\\View\\Components\\BtnAssignpoint",
        "App\\View\\Components\\LinkClickable",
        "App\\View\\Components\\RadialVote"
      ],
      "composers": [
        "App\\View\\Composers\\App",
        "App\\View\\Composers\\Archive",
        "App\\View\\Composers\\Auth",
        "App\\View\\Composers\\Brand",
        "App\\View\\Composers\\Homepage",
        "App\\View\\Composers\\Menu",
        "App\\View\\Composers\\Post",
        "App\\View\\Composers\\Product",
        "App\\View\\Composers\\ProductTest",
        "App\\View\\Composers\\Related",
        "App\\View\\Composers\\Review",
        "App\\View\\Composers\\Search"
      ]
    }
  }

but nothing change.

If I look into /srv/www/my_site/current/vendor/composer/autoload_classmap.php components are present.

I do not understand why in local all works fine, but in production server none.

when I create a component from wp acorn cli it create a class that use
use Illuminate\View\Component;

instead of
use Roots\Acorn\View\Component;

I try to use this component class… but nothing change in production…

Maybe this
Wp acorn cli create

    public function render()
    {
        return view('components.button');
    }

I need

    public function render()
    {
        return $this->view('components.button');
    }

Nothing… please help me :\

does <x-link-clickable ... /> work?

None

But

For some reason I thought that when I’m deploying the project … running composer install it should also do composer dump-autoload…

I added immediately after the composer install task … the composer dump-autoload task

And it all seems to work!