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

vincej's avatar
Level 15

Upgrade to Laravel 8 and PHP 8 Gives Laravel Error

I followed the recommendations on the L8 docs and I am now getting this error. Everything worked fine in L7.2. I tried just doing a simple "hello World" in L8 and it worked fine:

method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given

The laravel debug console says the problem stems within my view inside form builder

C:\laragon\www\KidsClub\vendor\laravelcollective\html\src\FormBuilder.php:1365

but I can not see for the life of me where this could be. Does this mean Form Builder no longer works with L8?

I could post the whole of my view, but it is quite long.

Many thanks !

0 likes
8 replies
vincej's avatar
Level 15

Thanks for your replies. Ok, cleared cache, cleared views - nothing changed. Collective site only goes as far as 6.x.

vincej's avatar
Level 15

@jlrdw Looks like you found the issue. Collective is not yet compatible with PHP8. Thanks for that. I will have to revert back to 7.2 as I have too many collective statements to change them all.

cheers !

Talinon's avatar

@vincej The version numbers between Collective and the Laravel Framework are not aligned. Collective version 6.2 has support for Laravel 8.

I do not believe your issue is with Laravel 8, but is a compatibility problems with PHP 8 and the Collective package. You can see a Pull Request here with the same error you have:

https://github.com/LaravelCollective/html/pull/671

So, I think your options are:

  1. Get rid of the package and update your views to NOT use Collective (many developers have gone this way)
  2. Downgrade PHP
  3. Install a fork of Collective where they have the fix

For #3 - see https://github.com/repat/html

1 like
vincej's avatar
Level 15

@talinon Thanks for that. I believe you are correct. My main project has been developed over several years and has thousands of Collective entries. So, updating my views is not much of an option. In the short term I will have to downgrade until either I have the energy to fix all the collective entries, or downgrade back to ^7.0 . I will downgrade.

This is why I time using small time companies who have a great idea and then after a few years get board and stop supporting their product. I have been caught by this so many time.

Thanks !

vincej's avatar
Level 15

Ok, so I've decided after all, that I would prefer to import the Collective fork with the fix. But, here is the dumb question, I have never had the need to do this, having always imported stuff with packagist and composer.

So, any advice on how to import a fork would be very appreciated.

Many thanks !

Talinon's avatar

@vincej This video should help:

https://laracasts.com/series/whats-new-in-laravel-8/episodes/11

Around the 5 minute mark, Jeffrey demonstrates how you can use a forked version in place of a package.

If you have issues with the fork, a last resort option would be (and I even hate myself while typing this as its a cardinal sin) to change the source code in the vendor directory. I only mention this because it's such a small change, and it is likely temporary until laravelcollective/html updates or merges the PR.

You can see the change here:

https://github.com/LaravelCollective/html/pull/671/commits/06ae76ab165af1cbf16103f0bf442363a90799e6

It's just a one-liner... if you're really careful until they update their repo, you could just slip that into the vendor source. You Just need to remember it'll revert back if you ever run a composer update/install.

1 like

Please or to participate in this conversation.