Cannot get new composers to work

Hi,

I don’t know why, but it seems that my composers wont load into the views. The standard App composer does work…

My composer ShopArchive.php:

<?php

namespace App\View\Composers;

use Roots\Acorn\View\Composer;

class ShopArchive extends Composer
{
    /**
     * List of views served by this composer.
     *
     * @var array[]
     */
    protected static $views = [
        'layouts.shop-archive',
    ];

    /**
     * Data to be passed to view before rendering.
     *
     * @return array
     */
    public function with()
    {
        return [
            'title' => 'test',
        ];
    }

    public function title() {
        return get_the_title();
    }

    
}

composer.json:

{
  "name": "roots/sage",
  "type": "wordpress-theme",
  "license": "MIT",
  "description": "WordPress starter theme with a modern development workflow",
  "homepage": "https://roots.io/sage/",
  "authors": [
    {
      "name": "Ben Word",
      "email": "ben@benword.com",
      "homepage": "https://github.com/retlehs"
    },
    {
      "name": "Scott Walkinshaw",
      "email": "scott.walkinshaw@gmail.com",
      "homepage": "https://github.com/swalkinshaw"
    },
    {
      "name": "QWp6t",
      "email": "hi@qwp6t.me",
      "homepage": "https://github.com/qwp6t"
    },
    {
      "name": "Brandon Nifong",
      "email": "brandon@tendency.me",
      "homepage": "https://github.com/log1x"
    }
  ],
  "keywords": [
    "wordpress"
  ],
  "support": {
    "issues": "https://github.com/roots/sage/issues",
    "forum": "https://discourse.roots.io/"
  },
  "autoload": {
    "psr-4": {
      "App\\": "app/"
    }
  },
  "require": {
    "php": "^8.0",
    "generoi/sage-woocommerce": "^1.1",
    "log1x/acf-composer": "^2.1",
    "log1x/navi": "^2.0",
    "log1x/poet": "^2.0",
    "log1x/sage-directives": "^2.0",
    "roots/acorn": "^3.2"
  },
  "require-dev": {
    "squizlabs/php_codesniffer": "3.7.2"
  },
  "suggest": {
    "log1x/sage-directives": "A collection of useful Blade directives for WordPress and Sage (^1.0).",
    "log1x/sage-svg": "A useful SVG directive for inlining SVG's within Blade views (^1.0)."
  },
  "config": {
    "optimize-autoloader": true,
    "preferred-install": "dist",
    "sort-packages": true
  },
  "minimum-stability": "dev",
  "prefer-stable": true,
  "scripts": {
    "lint": [
      "phpcs --extensions=php --standard=PSR12 app"
    ],
    "post-autoload-dump": [
      "Roots\\Acorn\\ComposerScripts::postAutoloadDump"
    ]
  },
  "extra": {
    "acorn": {
      "providers": [
        "App\\Providers\\ThemeServiceProvider"
      ]
    }
  }
}

Log1x’s Navi wont work for me aswell.

Hey @Menno

I am not sure how looks your layouts shop-archive but in with() function you should return title() function with $this->title().
I’ve tested this example and works as expected.

// Composer:

<?php

namespace App\View\Composers;

use Roots\Acorn\View\Composer;

class ShopArchive extends Composer
{
    /**
     * List of views served by this composer.
     *
     * @var string[]
     */
    protected static $views = [
        'layouts.shop-archive',
    ];

    /**
     * Data to be passed to view before rendering.
     *
     * @return array
     */
    public function with()
    {
        return [
            'title' => $this->title(),
        ];
    }


    public function title() {
        return get_the_title();
    }
}

// Layout shop-arhchive

<a class="sr-only focus:not-sr-only" href="#main">
  {{ __('Skip to content') }}
</a>

@include('sections.header')

  <main id="main" class="main">
    @yield('content')

    <p class="text-red-500 font-bold text-xl"> {!! $title !!}</p>
  </main>


@include('sections.footer')

// Page:

@extends('layouts.shop-archive')

@section('content')
  @while(have_posts()) @php(the_post())
    @include('partials.page-header')
    @includeFirst(['partials.content-page', 'partials.content'])
  @endwhile
@endsection

Hi @Jacek,

Thanks for the fast response.

Layout looks like this:

<a class="sr-only focus:not-sr-only" href="#main">
    {{ __('Skip to content') }}
  </a>
  
  @include('sections.header')
  
    <main id="main" class="main">
        @yield('page_title')
        @yield('content')
    </main>
  
    @hasSection('sidebar')
      <aside class="sidebar">
        @yield('sidebar')
      </aside>
    @endif
  
  @include('sections.footer')
  

My page looks like this (archive-product.blade.php):

@extends('layouts.shop-archive')

@section('page_title')
{{woocommerce_breadcrumb()}}
<h1>{{$title}}</h1>

@if (is_product_category())
  @php
    $cat = get_queried_object();
    $cat_desc = $cat->description;
  @endphp
  @if ($cat_desc)
    <p class="cat__description">{!!$cat_desc!!}</p>
  @endif
@endif

@endsection

@section('content')

  @if (woocommerce_product_loop())
    @php
      do_action('woocommerce_before_shop_loop');
      woocommerce_product_loop_start();
    @endphp

    @if (wc_get_loop_prop('total'))
      @while (have_posts())
        @php
          the_post();
          // do_action('woocommerce_shop_loop');
          wc_get_template_part('content', 'product');
          @endphp
      @endwhile
    @endif

    @php
      woocommerce_product_loop_end();
      do_action('woocommerce_after_shop_loop');
    @endphp
  @else
    @php
      do_action('woocommerce_no_products_found')
    @endphp
  @endif

  @php
    do_action('woocommerce_after_main_content');
    do_action('get_sidebar', 'shop');
    do_action('get_footer', 'shop');
  @endphp
@endsection

I changed the title to ‘test’ so I could test if it wasn’t an error in my function. However, it doesn’t matter. It returns this error:

( ! ) Warning: Undefined variable $title in /Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework/views/7afcc0a216a83576ed25911cf93dc42dc6a6ad65.php on line 4

I create every component or composer using the Acorn commands, so it should work out of the box.

FWIW: I’m using Valet as my development env, op-cache and xdebug are activated. Site is running on PHP 8.1

Please check documentation with composers.

The error actually said everything, you use variable which is not defined in current view.

<h1>{{$title}}</h1>

The thing is, the variable is assigned (as you can see in my files). I assigned the correct views and am returning the proper data.
When I add the view inside the standard App.php Composer it does render my title variable. Which means that my created Composers wont auto-load, right?

you try to use $title in file:

but in your composer you have set view where data will be returned:

layouts.shop-archive

So as my above example, try to return $title in layouts/shop-archive.blade.php not archive-product.blade.php

Still an undefined variable error.

<a class="sr-only focus:not-sr-only" href="#main">
    {{ __('Skip to content') }}
  </a>
  
  @include('sections.header')
  
    <main id="main" class="main">
        {!! $title !!}
        @yield('page_title')
        @yield('content')
    </main>
  
    @hasSection('sidebar')
      <aside class="sidebar">
        @yield('sidebar')
      </aside>
    @endif
  
  @include('sections.footer')
  

Path of layout: resources/views/layouts/shop-archive.blade.php
Path of composer: app/View/Composers/ShopArchive.php

Could you paste your current code:

  1. Composer file
  2. blade shop-archive
  3. blade archive-product
  4. error message

Composer file:

<?php

namespace App\View\Composers;
use Roots\Acorn\View\Composer;
class ShopArchive extends Composer
{
    /**
     * List of views served by this composer.
     *
     * @var array[]
     */
    protected static $views = [
        'layouts.shop-archive',
    ];

    /**
     * Data to be passed to view before rendering.
     *
     * @return array
     */
    public function with()
    {
        return [
            'title' => $this->title(),
        ];
    }

    public function title() {
        // if is woocommerce template
        if (is_woocommerce()) {
            return woocommerce_page_title(false);
        }
        return get_the_title();
    }


    
}

shop-archive:

<a class="sr-only focus:not-sr-only" href="#main">
    {{ __('Skip to content') }}
  </a>
  
  @include('sections.header')
  
    <main id="main" class="main">
        {!! $title !!}
        @yield('page_title')
        @yield('content')
    </main>
  
    @hasSection('sidebar')
      <aside class="sidebar">
        @yield('sidebar')
      </aside>
    @endif
  
  @include('sections.footer')
  

archive-product:

{{--
The Template for displaying product archives, including the main shop page which is a post type archive

This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php.

HOWEVER, on occasion WooCommerce will need to update template files and you
(the theme developer) will need to copy the new files to your theme to
maintain compatibility. We try to do this as little as possible, but it does
happen. When this occurs the version of the template file will be bumped and
the readme will list any important changes.

@see https://docs.woocommerce.com/document/template-structure/
@package WooCommerce/Templates
@version 3.4.0
--}}

@extends('layouts.shop-archive')

@section('page_title')
{{woocommerce_breadcrumb()}}
<h1>{!!$title!!}</h1>

@if (is_product_category())
  @php
    $cat = get_queried_object();
    $cat_desc = $cat->description;
  @endphp
  @if ($cat_desc)
    <p class="cat__description">{!!$cat_desc!!}</p>
  @endif
@endif

@endsection

@section('content')
  </div>
  
  @if (woocommerce_product_loop())
  @php
      do_action('woocommerce_before_shop_loop');
      woocommerce_product_loop_start();
    @endphp

    @if (wc_get_loop_prop('total'))
    <section class="section__wrapper">
    <div class="producten__wrapper grid-1-2">
      <div class="producten__filter">
        @php
        wpgb_render_facet( [ 'id' => 9, 'grid' => 'wpgb-content' ] );
        wpgb_render_facet( [ 'id' => 10, 'grid' => 'wpgb-content' ] );
        wpgb_render_facet( [ 'id' => 11, 'grid' => 'wpgb-content' ] );
        @endphp
      </div>
      <div class="producten__container grid-3 grid-m-1">
        @while (have_posts())
        @php
          the_post();
          // do_action('woocommerce_shop_loop');
          wc_get_template_part('content', 'product');
          @endphp
      @endwhile
    </div>
  </div>
  </section>

    @endif

    @php
      woocommerce_product_loop_end();
      do_action('woocommerce_after_shop_loop');
    @endphp
  @else
    @php
      do_action('woocommerce_no_products_found')
    @endphp
  @endif

  @php
    do_action('woocommerce_after_main_content');
    do_action('get_sidebar', 'shop');
    do_action('get_footer', 'shop');
  @endphp
@endsection

Error:

( ! ) Warning: Undefined variable $title in /Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework/views/7afcc0a216a83576ed25911cf93dc42dc6a6ad65.php on line 4
Call Stack
#	Time	Memory	Function	Location
1	0.0002	369160	{main}( )	.../server.php:0
2	0.0052	375816	require( '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/index.php )	.../server.php:110
3	0.0052	376128	require( '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-blog-header.php )	.../index.php:17
4	0.3166	11942664	require_once( '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-includes/template-loader.php )	.../wp-blog-header.php:19
5	0.3238	11971888	include( '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/index.php )	.../template-loader.php:106
6	0.3561	13559208	Illuminate\View\View->render( $callback = ??? )	.../index.php:14
7	0.3561	13559208	Illuminate\View\View->renderContents( )	.../View.php:147
8	0.3584	13601016	Illuminate\View\View->getContents( )	.../View.php:178
9	0.3584	13601392	Illuminate\View\Engines\PhpEngine->get( $path = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/plugins/woocommerce/templates/taxonomy-product-cat.php', $data = ['__env' => class Illuminate\View\Factory { protected $engines = class Illuminate\View\Engines\EngineResolver { ... }; protected $finder = class Roots\Acorn\View\FileViewFinder { ... }; protected $events = class Illuminate\Events\Dispatcher { ... }; protected $container = class Roots\Acorn\Application { ... }; protected $shared = [...]; protected $extensions = [...]; protected $composers = [...]; protected $renderCount = 2; protected $renderedOnce = [...]; protected $componentStack = [...]; protected $componentData = [...]; protected $currentComponentData = [...]; protected $slots = [...]; protected $slotStack = [...]; protected $fragments = [...]; protected $fragmentStack = [...]; protected $sections = [...]; protected $sectionStack = [...]; protected $loopsStack = [...]; protected $pushes = [...]; protected $prepends = [...]; protected $pushStack = [...]; protected $translationReplacements = [...] }, 'app' => class Roots\Acorn\Application { protected $resolved = [...]; protected $bindings = [...]; protected $methodBindings = [...]; protected $instances = [...]; protected $scopedInstances = [...]; protected $aliases = [...]; protected $abstractAliases = [...]; protected $extenders = [...]; protected $tags = [...]; protected $buildStack = [...]; protected $with = [...]; public $contextual = [...]; protected $reboundCallbacks = [...]; protected $globalBeforeResolvingCallbacks = [...]; protected $globalResolvingCallbacks = [...]; protected $globalAfterResolvingCallbacks = [...]; protected $beforeResolvingCallbacks = [...]; protected $resolvingCallbacks = [...]; protected $afterResolvingCallbacks = [...]; protected $basePath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise'; protected $hasBeenBootstrapped = TRUE; protected $booted = TRUE; protected $bootingCallbacks = [...]; protected $bootedCallbacks = [...]; protected $terminatingCallbacks = [...]; protected $serviceProviders = [...]; protected $loadedProviders = [...]; protected $deferredServices = [...]; protected $appPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/app'; protected $databasePath = NULL; protected $langPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/lang'; protected $storagePath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn'; protected $environmentPath = NULL; protected $environmentFile = '.env'; protected $isRunningInConsole = FALSE; protected $namespace = 'App\\'; protected $absoluteCachePathPrefixes = [...]; protected $bootstrapPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework'; protected $configPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/config'; protected $publicPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/public'; protected $resourcesPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/resources' }, 'siteName' => 'Surfparadise', 'siteLogo' => '<img src="https://woo-sage.test/wp-content/uploads/2023/11/surfparadise-logo.svg" class="attachment-full size-full" alt="" decoding="async" />'] )	.../View.php:195
10	0.3584	13601392	Illuminate\View\Engines\PhpEngine->evaluatePath( $path = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/plugins/woocommerce/templates/taxonomy-product-cat.php', $data = ['__env' => class Illuminate\View\Factory { protected $engines = class Illuminate\View\Engines\EngineResolver { ... }; protected $finder = class Roots\Acorn\View\FileViewFinder { ... }; protected $events = class Illuminate\Events\Dispatcher { ... }; protected $container = class Roots\Acorn\Application { ... }; protected $shared = [...]; protected $extensions = [...]; protected $composers = [...]; protected $renderCount = 2; protected $renderedOnce = [...]; protected $componentStack = [...]; protected $componentData = [...]; protected $currentComponentData = [...]; protected $slots = [...]; protected $slotStack = [...]; protected $fragments = [...]; protected $fragmentStack = [...]; protected $sections = [...]; protected $sectionStack = [...]; protected $loopsStack = [...]; protected $pushes = [...]; protected $prepends = [...]; protected $pushStack = [...]; protected $translationReplacements = [...] }, 'app' => class Roots\Acorn\Application { protected $resolved = [...]; protected $bindings = [...]; protected $methodBindings = [...]; protected $instances = [...]; protected $scopedInstances = [...]; protected $aliases = [...]; protected $abstractAliases = [...]; protected $extenders = [...]; protected $tags = [...]; protected $buildStack = [...]; protected $with = [...]; public $contextual = [...]; protected $reboundCallbacks = [...]; protected $globalBeforeResolvingCallbacks = [...]; protected $globalResolvingCallbacks = [...]; protected $globalAfterResolvingCallbacks = [...]; protected $beforeResolvingCallbacks = [...]; protected $resolvingCallbacks = [...]; protected $afterResolvingCallbacks = [...]; protected $basePath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise'; protected $hasBeenBootstrapped = TRUE; protected $booted = TRUE; protected $bootingCallbacks = [...]; protected $bootedCallbacks = [...]; protected $terminatingCallbacks = [...]; protected $serviceProviders = [...]; protected $loadedProviders = [...]; protected $deferredServices = [...]; protected $appPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/app'; protected $databasePath = NULL; protected $langPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/lang'; protected $storagePath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn'; protected $environmentPath = NULL; protected $environmentFile = '.env'; protected $isRunningInConsole = FALSE; protected $namespace = 'App\\'; protected $absoluteCachePathPrefixes = [...]; protected $bootstrapPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework'; protected $configPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/config'; protected $publicPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/public'; protected $resourcesPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/resources' }, 'siteName' => 'Surfparadise', 'siteLogo' => '<img src="https://woo-sage.test/wp-content/uploads/2023/11/surfparadise-logo.svg" class="attachment-full size-full" alt="" decoding="async" />'] )	.../PhpEngine.php:38
11	0.3584	13617904	Illuminate\Filesystem\Filesystem->getRequire( $path = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/plugins/woocommerce/templates/taxonomy-product-cat.php', $data = ['__env' => class Illuminate\View\Factory { protected $engines = class Illuminate\View\Engines\EngineResolver { ... }; protected $finder = class Roots\Acorn\View\FileViewFinder { ... }; protected $events = class Illuminate\Events\Dispatcher { ... }; protected $container = class Roots\Acorn\Application { ... }; protected $shared = [...]; protected $extensions = [...]; protected $composers = [...]; protected $renderCount = 2; protected $renderedOnce = [...]; protected $componentStack = [...]; protected $componentData = [...]; protected $currentComponentData = [...]; protected $slots = [...]; protected $slotStack = [...]; protected $fragments = [...]; protected $fragmentStack = [...]; protected $sections = [...]; protected $sectionStack = [...]; protected $loopsStack = [...]; protected $pushes = [...]; protected $prepends = [...]; protected $pushStack = [...]; protected $translationReplacements = [...] }, 'app' => class Roots\Acorn\Application { protected $resolved = [...]; protected $bindings = [...]; protected $methodBindings = [...]; protected $instances = [...]; protected $scopedInstances = [...]; protected $aliases = [...]; protected $abstractAliases = [...]; protected $extenders = [...]; protected $tags = [...]; protected $buildStack = [...]; protected $with = [...]; public $contextual = [...]; protected $reboundCallbacks = [...]; protected $globalBeforeResolvingCallbacks = [...]; protected $globalResolvingCallbacks = [...]; protected $globalAfterResolvingCallbacks = [...]; protected $beforeResolvingCallbacks = [...]; protected $resolvingCallbacks = [...]; protected $afterResolvingCallbacks = [...]; protected $basePath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise'; protected $hasBeenBootstrapped = TRUE; protected $booted = TRUE; protected $bootingCallbacks = [...]; protected $bootedCallbacks = [...]; protected $terminatingCallbacks = [...]; protected $serviceProviders = [...]; protected $loadedProviders = [...]; protected $deferredServices = [...]; protected $appPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/app'; protected $databasePath = NULL; protected $langPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/lang'; protected $storagePath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn'; protected $environmentPath = NULL; protected $environmentFile = '.env'; protected $isRunningInConsole = FALSE; protected $namespace = 'App\\'; protected $absoluteCachePathPrefixes = [...]; protected $bootstrapPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework'; protected $configPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/config'; protected $publicPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/public'; protected $resourcesPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/resources' }, 'siteName' => 'Surfparadise', 'siteLogo' => '<img src="https://woo-sage.test/wp-content/uploads/2023/11/surfparadise-logo.svg" class="attachment-full size-full" alt="" decoding="async" />'] )	.../PhpEngine.php:58
12	0.3585	13618688	Illuminate\Filesystem\Filesystem::Illuminate\Filesystem\{closure:/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/vendor/illuminate/filesystem/Filesystem.php:106-110}( )	.../Filesystem.php:110
13	0.3585	13619000	require( '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/plugins/woocommerce/templates/taxonomy-product-cat.php )	.../Filesystem.php:109
14	0.3585	13619000	wc_get_template( $template_name = 'archive-product.php', $args = ???, $template_path = ???, $default_path = ??? )	.../taxonomy-product-cat.php:22
15	0.3588	13622888	include( '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework/views/0ef275f82026b05443a94336e2fab3f2-loader.php )	.../wc-core-functions.php:345
16	0.3588	13625664	Illuminate\View\View->render( $callback = ??? )	.../0ef275f82026b05443a94336e2fab3f2-loader.php:1
17	0.3588	13625664	Illuminate\View\View->renderContents( )	.../View.php:147
18	0.3591	13625792	Illuminate\View\View->getContents( )	.../View.php:178
19	0.3591	13626488	Illuminate\View\Engines\CompilerEngine->get( $path = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/resources/views/woocommerce/archive-product.blade.php', $data = ['__env' => class Illuminate\View\Factory { protected $engines = class Illuminate\View\Engines\EngineResolver { ... }; protected $finder = class Roots\Acorn\View\FileViewFinder { ... }; protected $events = class Illuminate\Events\Dispatcher { ... }; protected $container = class Roots\Acorn\Application { ... }; protected $shared = [...]; protected $extensions = [...]; protected $composers = [...]; protected $renderCount = 2; protected $renderedOnce = [...]; protected $componentStack = [...]; protected $componentData = [...]; protected $currentComponentData = [...]; protected $slots = [...]; protected $slotStack = [...]; protected $fragments = [...]; protected $fragmentStack = [...]; protected $sections = [...]; protected $sectionStack = [...]; protected $loopsStack = [...]; protected $pushes = [...]; protected $prepends = [...]; protected $pushStack = [...]; protected $translationReplacements = [...] }, 'app' => class Roots\Acorn\Application { protected $resolved = [...]; protected $bindings = [...]; protected $methodBindings = [...]; protected $instances = [...]; protected $scopedInstances = [...]; protected $aliases = [...]; protected $abstractAliases = [...]; protected $extenders = [...]; protected $tags = [...]; protected $buildStack = [...]; protected $with = [...]; public $contextual = [...]; protected $reboundCallbacks = [...]; protected $globalBeforeResolvingCallbacks = [...]; protected $globalResolvingCallbacks = [...]; protected $globalAfterResolvingCallbacks = [...]; protected $beforeResolvingCallbacks = [...]; protected $resolvingCallbacks = [...]; protected $afterResolvingCallbacks = [...]; protected $basePath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise'; protected $hasBeenBootstrapped = TRUE; protected $booted = TRUE; protected $bootingCallbacks = [...]; protected $bootedCallbacks = [...]; protected $terminatingCallbacks = [...]; protected $serviceProviders = [...]; protected $loadedProviders = [...]; protected $deferredServices = [...]; protected $appPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/app'; protected $databasePath = NULL; protected $langPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/lang'; protected $storagePath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn'; protected $environmentPath = NULL; protected $environmentFile = '.env'; protected $isRunningInConsole = FALSE; protected $namespace = 'App\\'; protected $absoluteCachePathPrefixes = [...]; protected $bootstrapPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework'; protected $configPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/config'; protected $publicPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/public'; protected $resourcesPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/resources' }, 'template_name' => 'archive-product.php', 'args' => [], 'template_path' => '', 'default_path' => '', 'cache_key' => 'template-archive-productphp---831', 'template' => '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework/views/0ef275f82026b05443a94336e2fab3f2-loader.php', 'cache_path' => '{{WP_CONTENT_DIR}}/cache/acorn/framework/views/0ef275f82026b05443a94336e2fab3f2-loader.php', 'filter_template' => '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework/views/0ef275f82026b05443a94336e2fab3f2-loader.php', 'action_args' => ['template_name' => 'archive-product.php', 'template_path' => '', 'located' => '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework/views/0ef275f82026b05443a94336e2fab3f2-loader.php', 'args' => [...]], 'siteName' => 'Surfparadise', 'siteLogo' => '<img src="https://woo-sage.test/wp-content/uploads/2023/11/surfparadise-logo.svg" class="attachment-full size-full" alt="" decoding="async" />'] )	.../View.php:195
20	0.3591	13627248	Illuminate\View\Engines\PhpEngine->evaluatePath( $path = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework/views/7afcc0a216a83576ed25911cf93dc42dc6a6ad65.php', $data = ['__env' => class Illuminate\View\Factory { protected $engines = class Illuminate\View\Engines\EngineResolver { ... }; protected $finder = class Roots\Acorn\View\FileViewFinder { ... }; protected $events = class Illuminate\Events\Dispatcher { ... }; protected $container = class Roots\Acorn\Application { ... }; protected $shared = [...]; protected $extensions = [...]; protected $composers = [...]; protected $renderCount = 2; protected $renderedOnce = [...]; protected $componentStack = [...]; protected $componentData = [...]; protected $currentComponentData = [...]; protected $slots = [...]; protected $slotStack = [...]; protected $fragments = [...]; protected $fragmentStack = [...]; protected $sections = [...]; protected $sectionStack = [...]; protected $loopsStack = [...]; protected $pushes = [...]; protected $prepends = [...]; protected $pushStack = [...]; protected $translationReplacements = [...] }, 'app' => class Roots\Acorn\Application { protected $resolved = [...]; protected $bindings = [...]; protected $methodBindings = [...]; protected $instances = [...]; protected $scopedInstances = [...]; protected $aliases = [...]; protected $abstractAliases = [...]; protected $extenders = [...]; protected $tags = [...]; protected $buildStack = [...]; protected $with = [...]; public $contextual = [...]; protected $reboundCallbacks = [...]; protected $globalBeforeResolvingCallbacks = [...]; protected $globalResolvingCallbacks = [...]; protected $globalAfterResolvingCallbacks = [...]; protected $beforeResolvingCallbacks = [...]; protected $resolvingCallbacks = [...]; protected $afterResolvingCallbacks = [...]; protected $basePath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise'; protected $hasBeenBootstrapped = TRUE; protected $booted = TRUE; protected $bootingCallbacks = [...]; protected $bootedCallbacks = [...]; protected $terminatingCallbacks = [...]; protected $serviceProviders = [...]; protected $loadedProviders = [...]; protected $deferredServices = [...]; protected $appPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/app'; protected $databasePath = NULL; protected $langPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/lang'; protected $storagePath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn'; protected $environmentPath = NULL; protected $environmentFile = '.env'; protected $isRunningInConsole = FALSE; protected $namespace = 'App\\'; protected $absoluteCachePathPrefixes = [...]; protected $bootstrapPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework'; protected $configPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/config'; protected $publicPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/public'; protected $resourcesPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/resources' }, 'template_name' => 'archive-product.php', 'args' => [], 'template_path' => '', 'default_path' => '', 'cache_key' => 'template-archive-productphp---831', 'template' => '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework/views/0ef275f82026b05443a94336e2fab3f2-loader.php', 'cache_path' => '{{WP_CONTENT_DIR}}/cache/acorn/framework/views/0ef275f82026b05443a94336e2fab3f2-loader.php', 'filter_template' => '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework/views/0ef275f82026b05443a94336e2fab3f2-loader.php', 'action_args' => ['template_name' => 'archive-product.php', 'template_path' => '', 'located' => '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework/views/0ef275f82026b05443a94336e2fab3f2-loader.php', 'args' => [...]], 'siteName' => 'Surfparadise', 'siteLogo' => '<img src="https://woo-sage.test/wp-content/uploads/2023/11/surfparadise-logo.svg" class="attachment-full size-full" alt="" decoding="async" />'] )	.../CompilerEngine.php:70
21	0.3591	13643760	Illuminate\Filesystem\Filesystem->getRequire( $path = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework/views/7afcc0a216a83576ed25911cf93dc42dc6a6ad65.php', $data = ['__env' => class Illuminate\View\Factory { protected $engines = class Illuminate\View\Engines\EngineResolver { ... }; protected $finder = class Roots\Acorn\View\FileViewFinder { ... }; protected $events = class Illuminate\Events\Dispatcher { ... }; protected $container = class Roots\Acorn\Application { ... }; protected $shared = [...]; protected $extensions = [...]; protected $composers = [...]; protected $renderCount = 2; protected $renderedOnce = [...]; protected $componentStack = [...]; protected $componentData = [...]; protected $currentComponentData = [...]; protected $slots = [...]; protected $slotStack = [...]; protected $fragments = [...]; protected $fragmentStack = [...]; protected $sections = [...]; protected $sectionStack = [...]; protected $loopsStack = [...]; protected $pushes = [...]; protected $prepends = [...]; protected $pushStack = [...]; protected $translationReplacements = [...] }, 'app' => class Roots\Acorn\Application { protected $resolved = [...]; protected $bindings = [...]; protected $methodBindings = [...]; protected $instances = [...]; protected $scopedInstances = [...]; protected $aliases = [...]; protected $abstractAliases = [...]; protected $extenders = [...]; protected $tags = [...]; protected $buildStack = [...]; protected $with = [...]; public $contextual = [...]; protected $reboundCallbacks = [...]; protected $globalBeforeResolvingCallbacks = [...]; protected $globalResolvingCallbacks = [...]; protected $globalAfterResolvingCallbacks = [...]; protected $beforeResolvingCallbacks = [...]; protected $resolvingCallbacks = [...]; protected $afterResolvingCallbacks = [...]; protected $basePath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise'; protected $hasBeenBootstrapped = TRUE; protected $booted = TRUE; protected $bootingCallbacks = [...]; protected $bootedCallbacks = [...]; protected $terminatingCallbacks = [...]; protected $serviceProviders = [...]; protected $loadedProviders = [...]; protected $deferredServices = [...]; protected $appPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/app'; protected $databasePath = NULL; protected $langPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/lang'; protected $storagePath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn'; protected $environmentPath = NULL; protected $environmentFile = '.env'; protected $isRunningInConsole = FALSE; protected $namespace = 'App\\'; protected $absoluteCachePathPrefixes = [...]; protected $bootstrapPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework'; protected $configPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/config'; protected $publicPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/public'; protected $resourcesPath = '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/resources' }, 'template_name' => 'archive-product.php', 'args' => [], 'template_path' => '', 'default_path' => '', 'cache_key' => 'template-archive-productphp---831', 'template' => '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework/views/0ef275f82026b05443a94336e2fab3f2-loader.php', 'cache_path' => '{{WP_CONTENT_DIR}}/cache/acorn/framework/views/0ef275f82026b05443a94336e2fab3f2-loader.php', 'filter_template' => '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework/views/0ef275f82026b05443a94336e2fab3f2-loader.php', 'action_args' => ['template_name' => 'archive-product.php', 'template_path' => '', 'located' => '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework/views/0ef275f82026b05443a94336e2fab3f2-loader.php', 'args' => [...]], 'siteName' => 'Surfparadise', 'siteLogo' => '<img src="https://woo-sage.test/wp-content/uploads/2023/11/surfparadise-logo.svg" class="attachment-full size-full" alt="" decoding="async" />'] )	.../PhpEngine.php:58
22	0.3591	13644544	Illuminate\Filesystem\Filesystem::Illuminate\Filesystem\{closure:/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/themes/surfparadise/vendor/illuminate/filesystem/Filesystem.php:106-110}( )	.../Filesystem.php:110
23	0.3591	13646048	require( '/Users/mennorogaar/Buro Brein/SynologyDrive/Projecten/- Development/woo-sage/wp-content/cache/acorn/framework/views/7afcc0a216a83576ed25911cf93dc42dc6a6ad65.php )	.../Filesystem.php:109

Remove $title variable from archive-product
Line 4.

To remove:

<h1>{!!$title!!}</h1>

It should be:

Hi Jacek,
Already tried that, still same error :frowning:

Try to debug your controller using dd();

and you can try to clear compiled views with acorn

wp acorn view:clear

I’ve cleared the views, no luck.

I’ve tried dd($this) in the with() function and changing the $views to [*] of the Composer, doesn’t return anything.

<?php

namespace App\View\Composers;

use Roots\Acorn\View\Composer;

class ShopArchive extends Composer
{
    /**
     * List of views served by this composer.
     *
     * @var array[]
     */
    protected static $views = [
        '*',
    ];

    /**
     * Data to be passed to view before rendering.
     *
     * @return array
     */
    public function with()
    {
        dd($this);
        return [
            'title' => $this->title(),
        ];
    }

    public function title() {
        // if is woocommerce template
        if (is_woocommerce()) {
            return woocommerce_page_title(false);
        }
        return get_the_title();
    }   
}


@Jacek

Hi, I haven’t heard from you since this issue. I’ve did some digging on my own and found out that using woocommerce views (im using generoi/sage-woocommerce package) will break all other composers except for app. This is the composer where it goes wrong:

<?php

namespace App\View\Composers;

use Roots\Acorn\View\Composer;

class Product extends Composer
{
    /**
     * List of views served by this composer.
     *
     * @var string[]
     */
    protected static $views = [
        'sections.producten'
        'woocommerce.*' // This is causing the problem, when I delete it everything works fine.
    ];

    /**
     * Data to be passed to view before rendering.
     *
     * @return array
     */
    public function with()
    {
        return [
            'excerpt' => $this->excerpt(),
        ];
    }

    public function excerpt()
    {
        // make excerpt from product description
        $excerpt = get_the_excerpt();
        $excerpt = substr($excerpt, 0, 100);
        $excerpt = substr($excerpt, 0, strrpos($excerpt, ' '));
        $excerpt = $excerpt . '...';

        return $excerpt;
    }
}