Melt the butter in a heavy-based saucepan and add the onion. Cook over low heat, stirring occasionally, for 25 minutes, or until the onion is deep golden brown and beginning to caramelise.
Add the garlic and flour and stir continuously for 2 minutes. Gradually blend in the stock and the wine, stirring all the time, and bring to the boil. Add the bay leaf and thyme and season. Cover the pan and simmer for 25 minutes. Remove the bay leaf and thyme and check the seasoning. Preheat your grill (broiler).
Toast the bread, then put two slices in each of six warm soup bowls, and ladle the soup over the top. Sprinkle with the cheese and place under the hot grill until the cheese melts to golden brown. Serve immediately.