Undefined variable with Laravel app hosted in App Platform

I’m attempting to deploy a Laravel 8 app that uses a managed MySQL database to App Platform but seeing this error during deployment:

2023-01-08T16:12:58.283405616Z │        > Illuminate\Foundation\ComposerScripts::postAutoloadDump
2023-01-08T16:12:58.365340624Z │        > @php artisan package:discover --ansi
2023-01-08T16:13:01.437590868Z │        
2023-01-08T16:13:01.461467698Z │        In Connection.php line 712:
2023-01-08T16:13:01.461502691Z │                                                                                       
2023-01-08T16:13:01.461505582Z │          Undefined variable $host (SQL: select * from information_schema.tables wher  
2023-01-08T16:13:01.461507874Z │          e table_schema = website and table_name = errors and table_type = 'BASE TAB  
2023-01-08T16:13:01.461522132Z │          LE')                                                                         
2023-01-08T16:13:01.461527037Z │                                                                                       
2023-01-08T16:13:01.461529776Z │        
2023-01-08T16:13:01.466120248Z │        In MySqlConnector.php line 154:
2023-01-08T16:13:01.466140089Z │                                    
2023-01-08T16:13:01.466143440Z │          Undefined variable $host  
2023-01-08T16:13:01.466146446Z │                                    
2023-01-08T16:13:01.466150226Z │        

I’ve added the database to the app which set the DATABASE_URL environment variable and configured the trusted source. The app runs fine locally and can connect to this database without issue.

Any idea what I’ve missed?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Site Moderator
Site Moderator badge
January 9, 2023

Hi @scottmetoyer,

Can you please post the Environment Variables you’ve configured on your App Platform?

If unsure, you can follow this Doc on how to define them :

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel