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

BilalHaidar's avatar

How to handle exceptions thrown by Artisan:call()

Hello,

I am trying to automate running the migrations when hosting my app on Google Cloud App Engine and Cloud Build.

One option is to curl into an endpoint that runs the migration by code. (If you have other options to run migrations on Google App Engine, please do share with me).

Now, Inside the endpoint controller, I will have something similar to this:

try {
	  ...
      Artisan::call('migrate', [
        '--force' => true
       ]);
    } catch (Exception $e) {
      Response::make($e->getMessage(), 500);
    }

Is it enough to have a try/catch block to handle problems with the Artisan command to run the migrations?

I appreciate your feedback.

Thanks Bill

0 likes
0 replies

Please or to participate in this conversation.