Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of undefined constant JSON_INVALID_UTF8_SUBSTITUTE - assumed 'JSON_INVALID_UTF8_SUBSTITUTE'

Tags:

php

macos

laravel

I recently cloned a laravel project and after running composer install, I am getting this error

In LogManager.php line 416:

Use of undefined constant JSON_INVALID_UTF8_SUBSTITUTE - assumed 'JSON_INVALID_UTF8_SUBSTITUTE' 

I have checked the web for solutions but can't find any related. Any assistance, please?

Also, how can I find the LogManager.php? It doesn't seem to be available when I search with VSCode

like image 718
Chidi Nkwocha Avatar asked Jun 02 '20 11:06

Chidi Nkwocha


1 Answers

You should upgrade your php version to 7.2+. If that is not possible, here is a fix that i used. Just add this to your index.php file:

if (!defined('JSON_INVALID_UTF8_SUBSTITUTE')) {
    //PHP < 7.2 Define it as 0 so it does nothing
    define('JSON_INVALID_UTF8_SUBSTITUTE', 0);
}
like image 112
pho7on Avatar answered Nov 19 '22 18:11

pho7on