Emanuele Feronato provides a great explanation and code example for creating infinite terrain generation in Phaser 3: "When we deal with endless runner games, where the player runs along a terrain, we can see two main concepts applied in the generation of the terrain:
The first concept wants you to create various pre-built prefabs and just randomly merge them together to create an endless environment. This is the case of Spelunky, which although is not a horizontal endless runner it’s the perfect example of what I mean."