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

shawnyv's avatar
Level 13

Livewire 3 Computed Property Syntax Update Helper

Hey all,

I'm just going through the Livewire 2 => Livewire 3 update now on a large-ish project (>180 Livewire components).

I was having some issues with the new Computed Property syntax & behavior, so I created a little package to help out.

In Livewire 2, a computed property "foo" would be defined like this:

public function getFooProperty()
{
    return 'bar';
}

In Livewire 3, the same property would be defined like this:

#[Computed]
public function foo()
{
    return 'bar';
}

This package automates that update in your Livewire components folder.

In addition, (and this may just have been an error from my team that nobody else dealt with), I found a bunch of places in my code post-upgrade that was trying to re-set the computed property by doing

$this->foo = null;

So I created a separate command in the package to deal with that, properly using unset($this->foo) instead.

I'll be using this in at least one other client project shortly, so it made sense to have it as a package - hope it helps somebody else!

Package can be found here: https://github.com/shawnveltman/livewire-3-property-updater

0 likes
2 replies
shawnyv's avatar
Level 13

Followup - the $this->foo = null turned out to be part of my CSFixer rules... So I ended up also having to disable this rule:

            'no_unset_on_property'                             => true,
1 like
olakunle's avatar

That's really helpful, thanks! I'll definitely incorporate this into my next project.

Please or to participate in this conversation.