Livewire: Typed Properties Causing Syntax Errors

Created on 23 Nov 2020  路  3Comments  路  Source: livewire/livewire

Description

Whenever I use a PHP 7.4 typed property inside a component, regardless of the type, I am getting:

image

If I remove the word 'string' in front of $user, everything works again. I also tried to initialize the var as suggested elsewhere.

My component and template are very minimal.

Stripped-down, copy-pastable code snippets

App\Http\Livewire\Profile.php

<?php

namespace App\Http\Livewire;

use App\Models\User;
use Livewire\Component;

class Profile extends Component
{
    public string $user;

    public function render()
    {
        return view('livewire.profile');
    }
}

resources/views/livewire/profile.blade.php

<div>hey</div>

Context

  • Livewire version: 2.2.3
  • Laravel version: 8.14
  • Alpine version: 2.7.3
  • Browser: Chrome 87.0.4280.67

Most helpful comment

@nickpoulos can you double check that your web requests are actually being handled by php 7.4?

In your routes/web.php put phpinfo(); at the top and check what the browser says it is using.

All 3 comments

@nickpoulos can you double check that your web requests are actually being handled by php 7.4?

In your routes/web.php put phpinfo(); at the top and check what the browser says it is using.

@joshhanley wow you hit the nail on the head, thank you! It did not really seem like an Alpine error tbh.

I am running the latest version of Homestead which is supposed to run 7.4 by default, and I even checked php -v to make sure. But for some reason CLI was using 7.4 and FPM was using 7.3.

I am all set now.

馃憢 Oh Hi! I'm Squishy, the friendly jellyfish that manages Livewire issues.

I see this issue has been closed.

Here in the Livewire repo, we have an "issues can be closed guilt-free and without explanation" policy.

If for ANY reason you think this issue hasn't been resolved, PLEASE feel empowered to re-open it.

Re-opening actually helps us track which issues are a priority.

Reply "REOPEN" to this comment and we'll happily re-open it for you!

(More info on this philosophy here: https://twitter.com/calebporzio/status/1321864801295978497)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oliverbj picture oliverbj  路  3Comments

zepfietje picture zepfietje  路  3Comments

mokhosh picture mokhosh  路  4Comments

randohinn picture randohinn  路  3Comments

austenc picture austenc  路  3Comments