In a large skillet melt 2 tablespoons of the butter. Over medium high heat. Add the mushrooms and onions and cook, stirring frequently for about 8 minutes until the mushrooms and onions have browned up nicely and any excess liquid released by the mushrooms has evaporated. Add the garlic and the rosemary and stir for another minute until you can smell the garlic. Remove from the heat and cool completely. Stir in the gruyere cheese until completely blended.
Meanwhile, preheat the oven to 425 degrees. Unroll the chilled puff pastry onto its parchment paper on a rimmed baking sheet. Cut the puff pastry into 24 squares. Brush the beaten egg over the top over the whole sheet of puff pastry.
Place a heaping tablespoon of the onion mushroom mixture in the middle of each square, and spread it out, leaving a ¼-inch border plain at the edges of each of the squares. Place in the fridge to chill for 30 minutes.
Bake for 16 to 20 minutes until the puff pastry is golden brown and flaky and the mushroom mixture is hot, with the cheese becoming melty. Allow to sit for 2 minutes before serving hot.
Notes
The mushrooms mixture can be made up to 2 days ahead of time and stored in a tightly covered container in the fridge. You can spread if over the puff pastry straight from the fridge.Instead of rosemary you can sub in other herbs – thyme or marjoram would be a good choice.Think about sprinkling some crispy bits of crumbled bacon over the top of these little puffed tartlets if you like (though clearly they then cease to be vegetarian!)