depends_on controls start order and nothing else. The database container being started is not the database accepting connections, so the application starts, fails to connect, and exits.
services:
php:
depends_on: [mysql] # started, not ready
mysql:
image: mysql:5.7
Version 2 had condition: service_healthy; version 3 removed it for the same scheduling reason as volumes_from. The answer that works everywhere is for the application to retry its connection at startup, which it should do regardless because the database can also go away at three in the morning. A wait-for-it script in the entrypoint is the pragmatic middle ground.