Melt the butter in a large heavy-based pan over medium heat. Add the onions and cook for 20 minutes, stirring often, until caramelised and dark golden-brown. This step is very important as the colour of the onions at this stage will determine the colour of the final soup. Stir in the garlic and the flour and cook, stirring continuously for 1-2 minutes.