In your local development environment, if you want to run a script including gcloud commands, you should refer to the "Scripting gcloud CLI commands" documentation
page. In this local environment, it is unclear why you chose to use PHP and the shell_exec() command; you can run the script directly at the command prompt.
If you mean to run shell_exec() in the code of your deployed PHP app, this is not supported. App Engine Standard Environment does not allow system calls. In the Flexible Environment, the following functions are disabled: exec, passthru, proc_open, proc_close, shell_exec, show_source, symlink, system.