Skip to content
Advertisement

Laravel AbstractVariables.php line 54 Expected name to be a string

I am using Laravel 6 with visual studio code. The last successfully command i run is given below with their out put.

JavaScript

But after that, whatever command i do execute it gives me an error

JavaScript

I have tried to execute given below commands, but all of these ends up with above mentioned error.

JavaScript

I have tried to find out file named “AbstractVariables.php” and i did find it in given below directory

JavaScript

I have tried to read what is code is given on line 54 of file named “AbstractVariables.php”

JavaScript

And the comments above this function is…

JavaScript

So, it means it is searching environment variable some where and it is not able to find string there.

.env file in my profile has all variables name. Now, I am not able to understand what else is missing, I have done a lot of search on google but didn’t find any thing in this regard.

Advertisement

Answer

This problem occurred when I configured spatie/laravel-analytics to fetch google analytics data to display in admin panel of website. In order to make it functional it was required to add 'view_id' => env('ANALYTICS_VIEW_ID') in config/analytics.php file.

What mistake was done?

In config/analytics.php file I added view id without single quote mark which was wrong. Example is given below….

JavaScript

After that whenever I hit follow commands i get error

JavaScript

Error is given below…

JavaScript

How I solved issue?

I have updated config/analytics.php as per documentation and changed it like given below…

JavaScript

And in .env file added environment variable ANALYTICS_VIEW_ID

JavaScript

After that both commands php artisan config:clearand php artisan cache:clear worked perfectly.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement