Served warm from the oven, this yummy tart makes a terrific first course, or pair it with a simple salad for a tasty lunch or supper. Summer-ripe tomatoes are essential for the best flavor, although even somewhat lackluster tomatoes will get a boost from the hidden filling of caramelized onions, pesto and nutty Gruyere cheese.
The crust gets soggy quickly, so this isn't a recipe that can be made far in advance. If you have leftovers, warm the tart in a hot oven (425 degrees F) on a preheated baking sheet.
Roll the pastry dough into an 11-inch circle that is 1/8-inch thick. Line a cookie sheet with a sheet of parchment or silicone liner (like a Silpat). Transfer the pastry circle to the sheet pan and refrigerate at least 2 hours. (The best way to transfer the dough is to fold it in half, then fold in half again, so the dough is easier to pick up. Open the folded pastry into a flat circle on the lined baking sheet.)
Cut the onions in half through the stem end, then slice them crosswise into very thin slices (about 5 cups). Heat the oil in a large nonstick skillet over medium-high heat. Add the onions and stir continuously for 2 minutes. Reduce the heat to medium-low and add the salt. Cook the onions, stirring occasionally, until golden and very soft, 20 to 30 minutes. Add the garlic and cook another 2 minutes, stirring frequently. Remove the skillet from the heat. Cool to room temperature or chill, covered, for several hours or overnight.
Remove the stem ends from the tomatoes and cut them crosswise into 1/8-inch-thick slices. Place the slices on several thicknesses of paper towels to drain.
Position a rack in the bottom of the oven and preheat to 400 degrees F.
Remove the cookie sheet with the pastry from the refrigerator. Spread the Gruyère across the pastry, leaving a 1-inch border uncovered. Scatter the onion mixture on top of the cheese. Carefully spread the pesto over the onions, then top with a single layer of slightly overlapping tomato slices (you may not use them all). Season the tomatoes with salt and pepper.
Place the egg yolk and milk in a small cup and whisk to blend.
Fold the edges of the pastry over the filling, pinching and pleating the dough to form a rim that encases the filling. Brush the edges of the pastry with the egg wash. Sprinkle the Parmigiano Reggiano over the tomatoes and pastry edges.
Transfer the cookie sheet to the oven and bake until the juices bubble and the crust turns golden brown and crispy, 30 to 40 minutes.
Remove the cookie sheet from the oven and slide the tart (with the liner) onto a wire rack. Let cool for 10 minutes before slicing into wedges. Garnish with a drizzle of olive oil and a chiffonade of basil, if desired.