Hi, I looked up some causes of vomiting foamy phlegm and bile, and this is what I found for you:
Most of the time it is nothing to worry about, but it never hurts to get a second opinion or to ask your vet, if this becomes chronic or happens often.
SOME OF THE CAUSES ARE:
Regurgitation, it could be something he's swallowed or eaten coming back up.
Ingesting something toxic, or an obstruction somewhere
Bloating, swelling of the stomach
Bile in his stomach from having an empty stomach too long, this causes digestive acids and bike to accumulate in the stomach . When there is no food to digest, these liquids irritate the stomach lining causing reflux, which causes vomit with a yellowish bile. This usually happens first thing in the morning when they have an empty stomach.
An allergic reaction to something in his food
From eating grass, it is not uncommon for dogs to do this, as it makes them vomit. It is a defence mechanism should they feel they have eaten something bad.
It can be caused by over exercise, or eating too fast
Digestive tract problems, causes white foam vomit, and can be fixed by a change in food.
Obstruction , gastritis, ingestion of non food items, or eating too fast
DIFFERENT COLOURS OF BILE:
Yellow Bile: excess bile on the stomach, or eating grass
White Foam: eating garbage, spoiled food, or foreign substances, which can indicate an obstruction
WHEN IS VOMITING A SERIOUS PROBLEM:
Vomiiting more than once a day, or continuing on the next day.
Vomit with blood
Vomiting despite not eating for several hours
The best course of action is to keep your dog warm, hydrated, and comfortable, and to call your vet. There aren't many major problems that come from vomiting stomach bile, but it will soften their throat over time, and if your dog does vomit a lot, it could lead to burning of the esophagus. The usual cause of vomiting is some sort of intolerance in food, but if in doubt make an appointment to see your vet.
I hope this helps you, and it's nothing serious.