Shared services among multiple projects

Hello Docker community,

I am a PHP developer with a question regarding the setup of a unified configuration for multiple projects. I apologize if the question is poorly formulated or if it has already been addressed elsewhere. Below is my question:

Given:

  1. I have a directory named ‘workspace’ with two subdirectories: ‘global-services’ and ‘webapps.’
  2. In ‘global-services,’ I have my Dockerfile and docker-compose.yml with all services such as Php, MySQL, etc.
  3. When I run composer create symfony or laravel, the web apps are created inside the ‘webapps’ directory.
  4. Inside the newly created web app, I add a docker-compose.yml to make use of the global containers. (This step is failing)

Question: How can I access the services (Php/Composer, MySQL) from a web app? Is this a valid approach? At work, we define all dependencies/services per project.

Thank you all for your time; I am looking forward to your feedback.

Extra info:
Global docker-compose:
version: ‘3’

services:
php:
build:
context: .
dockerfile: Dockerfile
ports:
- “9000:9000”
volumes:
- ./php.ini:/usr/local/etc/php/php.ini
- …/apps:/var/www/html
depends_on:
- mysql

mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: global_database
MYSQL_USER: global_user
MYSQL_PASSWORD: global_password
ports:
- “3306:3306”
volumes:
- mysql-data:/var/lib/mysql

volumes:
composer-data:
mysql-data:

networks:
global-services-network:
external: true

Single project docker-compose:
version: ‘3’

services:
app:
build:
context: …/…/global-services/Dockerfile
ports:
- “8000:8000”
depends_on:
- php
- mysql

networks:
  - global-services-network
volumes:
  - ../apps/my_project_directory:/var/www/html

networks:
global-services-network:
external: true

Error message:
service “app” depends on undefined service php: invalid compose project
docker-compose process finished with exit code 15