Intermediate 6: Multi-app reusability
The information in this post is accurate as of the published date . Please make sure to check any linked documentation within the post for changes/updates.
A quick aside
You could very well add as many applications to your repository as you need to, building out a cluster of microservices dedicated to specific jobs in your final site.
Before we get into connecting them to each other, multi-app configuration also enables you to reuse code across applications.
If we imagine a simple PHP application with a web/index.php
entry point, we can define a shared applications.yaml
file to define the application.
The repository will look like this:
.
├── .platform
│ ├── applications.yaml
│ ├── services.yaml
│ └── routes.yaml
└── main-app
└── web
└── index.php
using an applications.yaml
file that can contain an array of app configurations:
- name: main
type: php:8.1
source:
root: main-app
web:
locations:
"/":
root: "web"
passthru: "/index.php"
We can add apps to this file (like a Next.js frontend in the previous step), but we can also reuse the codebase to build a completely separate application container in parallel.
- name: main
type: php:8.1
source:
root: main-app
web:
locations:
"/":
root: "web"
passthru: "/index.php"
- name: admin
type: php:8.1
source:
root: main-app
web:
locations:
"/":
root: "web"
passthru: "/admin.php"
Both apps (main
and admin
) use the main-app
subdirectory as their codebase, but handle requests differently. Any other configuration included in this file would likewise differentiate the two (i.e. mounts and crons).
Next: Connecting applications
Please sign in to leave a comment.
Comments
0 comments