• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • Support for BIND DNS has been removed from Plesk for Windows due to security and maintenance risks.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS.

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