• Dear Pleskians! The Plesk Forum will be undergoing scheduled maintenance on Monday, 7th of July, at 9:00 AM UTC. The expected maintenance window is 2 hours.
    Thank you in advance for your patience and understanding on the matter.

Issue Issue with Laravel Component Variable

eliamarsura

Basic Pleskian
Server operating system version
Debian 11.9
Plesk version and microupdate number
18.0.59.2
Hello :)

I'm using Plesk, and I've deployed a new Laravel application.

From the Laravel toolkit, I run the command
Code:
php artisan make:component sidebarnominativi
.

So far, so good. It creates the controller in
Code:
app/View/Components/sidebarnominativi.php
and the blade file in
Code:
resources/views/components/sidebarnominativi.blade.php
.

I open the controller and create a simple function that passes the variable `$nominativi`:

PHP:
public function render(): View|Closure|string

{

    $nominativi = "prova";

    return view('components.sidebarnominativi', compact('nominativi'));

}

I call it in the blade:

HTML:
<div>
    {{ $nominativi }}
</div>

I insert my component in `resources/views/welcome.blade.php` like this:

HTML:
<x-sidebarnominativi />

The result is that when I visit the project's homepage, I receive the error:

Code:
Undefined variable $nominativi (View: serverpath/resources/views/components/sidebarnominativi.blade.php)

Below are all the environment details:
- PHP Version: 8.3.4
- Laravel Version: 10.48.4
- Laravel Config Cached: false
- App Debug: true
- App Env: local

I've already tried the following commands:
- `php artisan view:cache`
- `php artisan view:clear`
- `composer update`
- `composer install`
- `composer dump`

None of these commands generate any errors, and they are not resolving the issue.

I've also tried changing the framework version to `v10.39.0`.

Has anyone ever encountered this issue before?
 
Back
Top