Start by making the pastry, if making your own. Do this by adding the flour and butter to a large bowl and rub together with your fingertips until roughly combined. You do not want to take it as far as breadcrumbs, there should still be bits of butter visible in places. Add the water and make into a ball. Wrap and chill for 30 mins, while making your onion filling.
Make the caramelised onions: Add your sliced onions, butter, oil and a little salt to a large pan. Place over a medium heat and begin to cook. We don't want to see any burning, so keep a jug of water or vegetable stock to one side and keep adding as the pan 'dries' and the onions soak it up.
Keep stirring and cooking, adding liquid to keep the onions moist and to prevent burning - it will take about 30 minutes. As the onions reach the deep caramelised stage, add the garlic and herbs and stir again. Season to taste before removing from the heat.
Remove the pastry from the fridge, roll in one direction to form a long rectangle. Fold the top edge down to just below the middle. Then fold the bottom edge over this, to form a square with 3 layers (book end). Rotate this block 90 Degrees and repeat. Wrap and chill for another 20 minutes, whilst the onions cool.
Preheat the oven to 250C/220C Fan/Gas 7. Line two large baking trays.
Take the pastry out of the fridge. Roll flat to about 1/2 thick and cut 4 equal squares from it. Place two squares on each tray. Add equal amounts of the onion filling to the middle of each square and spread a little in a diagonal direction (towards two opposite corners - so it's in a line).
Add the mixed grated cheeses, keeping a little back to sprinkle once the pastry gets wrapped. Wrap the pastry by folding two corners into the middle and pressing together. These should be the corners opposite the line of filling (so that the filling is exposed).
If using, brush a little beaten egg over the pastry. Sprinke over the remaining cheese. Bake for 12-15 minutes until golden brown. Remove and let cool on a wire rack before serving (although eating them whilst warm is a real joy).