I have problem in deploying my first larval project to Google Cloud.
If my question is silly, please give gentle comment. I am not php developer or not even web developer. I just would like to test it out and stuck in this issue for over 1 day.
I created one larval project with small database and few CRUD restful api. I tested with Postman in local and it is working fine. So I would like to upload to server and I choose Google Cloud Storage with App Engine. I followed this link - https://cloud.google.com/community/tutorials/run-laravel-on-appengine-flexible
I can see laravel home screen by calling http://MY_PROJECT_ID.appspot.com
I got error by calling my get api, http://MY_PROJECT_ID.appspot.com/users
So I thought I need to setup database. I follow instruction "Setup Database Session" from above link that I mentioned.
After that I called gcloud app deploy --project [MY_PROJECT_ID]
Then I got this following error:
[06-Mar-2018 03:36:44 UTC] [2018-03-06 03:36:44] production.ERROR: SQLSTATE[HY000] [2002] No such file or directory {"exception":"[object] (Doctrine\\DBAL\\Driver\\PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47, PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43)"} []
Step #1: [06-Mar-2018 03:36:44 UTC] [2018-03-06 03:36:44] production.ERROR: SQLSTATE[HY000] [2002] No such file or directory (SQL: delete from `cache`) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory (SQL: delete from `cache`) at /app/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, Doctrine\\DBAL\\Driver\\PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47, PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43)"} []
Step #1:
Step #1: In Connection.php line 664:
Step #1:
Step #1: SQLSTATE[HY000] [2002] No such file or directory (SQL: delete from `cache`)
Step #1:
Step #1:
Step #1: In PDOConnection.php line 47:
Step #1:
Step #1: SQLSTATE[HY000] [2002] No such file or directory
Step #1:
Step #1:
Step #1: In PDOConnection.php line 43:
Step #1:
Step #1: SQLSTATE[HY000] [2002] No such file or directory
Step #1:
Step #1:
Step #1: Script php artisan cache:clear handling the post-install-cmd event returned with error code 1
Step #1: The command '/bin/sh -c /build-scripts/composer.sh' returned a non-zero code: 1
Finished Step #1
ERROR
ERROR: build step 1 "gcr.io/cloud-builders/docker@sha256:5ebcd6cbf6e0a0279e25f8a1c73ae87f7d601fbb86f29a34a82110bd81249722" failed: exit status 1
I even don't know which step was wrong. Error log shows error is in script php artisan cache:clear, so I call this command individually and it is working well. I can feel some or many things are wrong. I was hoping that someone can point it out to me what was wrong.
Now I can deploy successfully by replacing:
with
in composer.json
But I got another problem after that.
I solved this problem changing in the app.yaml file the value of CACHE_DRIVER from "database" to "file".
When the value is set to "database" and the gcloud app deploy function run the php artisan cache:clear (indicated as post-install-cmd in composer.json) this will exec a query to delete the cache in a "cache" table on the database. But in my case and i guess also in yours we use a cache file and not a database table.
The same problem and the same solution works for session changing SESSION_DRIVER value to "file".