Melt the butter in a heavy-based saucepan on low heat.
Add the chopped garlic and sliced onions and continue to cook over low heat for about 30-45 minutes, stirring occasionally.
When the onion becomes golden brown and begins to caramelise, add the wine and allow it to boil until the alcohol is evaporated. Continue to gradually add the stock and bring the soup to boil.
Add the bay leaves and the thyme and season with salt and black pepper.
Cover the pan and continue to simmer for 25 minutes.
Before serving remove the thyme springs and the bay leaves.
Divide the soup into 6 warm bowls.
Preheat the oven at 180 C.
Arrange the baguette slices on a tray and top them with grated cheese. Place the tray in the oven (use the broiler function if available) and remove it when the cheese starts to melt.
Place two baguette slices in each bowl and garnish with thyme.