Passing variables works only in local env

Hello folks,

Dunno if this might be a bug in building process or a configuration in our process, Messing up the controllers, BUT

Exporting variables from controllers works fine only in local dev, when I go online, I need to declare the variable passing through the classname or the variable is undefined…

Previously I had a problem with a WP query making scope explode, could that be connected as somewhere else that issue could break some processes?
Or there something different I should check?

We also don’t know, this topic is confusing as-is. You’re going to need to provide code and not just words.

If you want to post up your problematic code along with an explanation with what you’ve tried so far to try to debug your problem, we’ll get this topic re-listed for you.

ok I get it :slight_smile:

//Related.php → this is partial, included in a page.


class Related extends Composer
{

    protected static $views = [
        'soci',
        'single-pianisanitari'
    ];

    public function with()
    {
        return [
            'RelatedPostsX'  => $this->getRelatedPosts(),
        ];
    }

    public function getRelatedPosts(): array
    {
        ...
           ...

        return $items;
    }
}

//partials/related.blade.php

...
@php 
$RelatedPosts = \App\View\Composers\Related::getRelatedPosts(); //this way it works everywhere...
@endphp
@if( count($RelatedPosts) > 0 )
         @foreach($RelatedPosts as $post)
         //do smt with $post['keys']
...
@if( count($RelatedPostsX) > 0 )
         @foreach($RelatedPostsX as $post)
         //RETURNS an undefined variable error ($RelatedPostsX) if live and not on local
     ```

  // # Environment
        WP_ENV="development" in local

      # Environment
       WP_ENV="staging" online.