Sancho
Sancho

Reputation: 1390

$env must not be accessed before initialization

I upgrade my project from SF 5.4 to SF 6 with php 8.1.2.

With my dev env I have no errors!

When I use the prod env when I cache clear I have the error:

In Route.php line 196:
                                                                                                              
  Typed property Symfony\Component\Routing\Annotation\Route::$env must not be accessed before initialization  

I try to remove the var/cache folder.

Do you have any ideas how to fix that one?

I found the same error in stack and I replace the handler_id with null value.

The error come from the SF router vendor. Route.php is not my own code.

Upvotes: 3

Views: 4189

Answers (1)

Joseph
Joseph

Reputation: 59

I have had the same issue so I cleared cache typing this command symfony console cache:clear to make all work again. You can also refer to this link if the need arises: $env not initialized

Upvotes: 5

Related Questions