Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Shedman's avatar

Blade Component not getting var on Forge

I have a site working on my local install. I loaded it to forge through github. The site works except for components. It is as if it is not even looking for the component.php.

<label for="product_material">Material:</label> 
                        
<div class="control">

    <select name="product_material" required>
        @foreach($materials AS $material)
            <option value="{{$material->material}}" {{ old('product_material') == $material->material || $slot == $material->material ? 'selected='.'"'.'selected'.'"' : ''   }}>{{$material->material}}</option>
        @endforeach
    </select>

</div>

Here is the component.php

<?php

namespace App\View\Components;

use Illuminate\View\Component;
use DB;

class material extends Component
{
    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\Contracts\View\View|string
     */
    public function render()
    {
        $material = DB::table('materials')->get();
       
        return view('components.material',['materials' => $material]);
    }
}

I get an error saying that "Undefined variable: materials."

What is strange is, if I add a dump to the file I get nothing.

 public function render()
    {
        $material = DB::table('materials')->get();
       DD($material);
        return view('components.material',['materials' => $material]);
    }

I would expect it to dump the materials retrieved from the DB. Yet it ignores this. That makes me think it is not even using the PHP component. I used tinker to execute the query and I get the results.

I have three similar components and all behave the same way.

0 likes
1 reply
Shedman's avatar

It appears that it is a case-sensitive issue. On my Mac using lower case component names is okay, but on Forge it needs to be upper case.

Please or to participate in this conversation.