Fruit flies are more or less essential food for most newly hatched mantids. Rearing them is easy. All that is required is a suitable container and some fruit. Job done! Well, there is a bit more to it if you want to make life easier for yourself.
Use a clear bottle of some description. A bottle has a relatively small opening so you can prevent most of the flies from escaping when you open the lid. I use glass 1 pint (568ml) milk bottles (height = 180mm).
You can use a piece of gauze held on with an elastic band. However, my rearing method doubles as a recapture method for those that inevitably escape when you are feeding your mantis. I make a cone out of paper (sticky tape to hold it in shape) and use this as the lid. The tip of the cone is cut off so there is a hole very slightly larger than a fruit fly; the point of the cone goes into the bottle. The wide end of the cone is repeatedly snipped so the flaps can fold down the outside of the rim of the bottle; this is held on with an elastic band. Flies loose in the room can crawl down the cone into the bottle. Flies in the bottle go up the side of the bottle but do not find the way out (the same principle as a lobster pot).
Put slices of fruit in the bottle. Apple, Pear, or Banana work well; do not peel the fruit. Softer fruits can be used but produce more juice. If the fruit is very juicy add some rolled oats (porridge oats) to soak up the excess moisture. To start the culture aim for about a 2cm depth of fruit in the jar. As the culture progresses you can add more oats or fruit as necessary. Don’t allow the food to become too wet, there is a risk the fruit fly larvae may drown, or at least have problems finding somewhere to pupate. With the correct balance of fruit and oats the food becomes solid enough for you to tip the bottle upside down to get flies out if you need to (experiment with care – messy if you get it wrong).
Once the larvae have grown large enough they will climb upwards to find somewhere to pupate. Usually they will pupate near the top of the bottle, or even on the lid. Condensation running down the inside of the bottle will mean the larvae cannot get up the side of the bottle. A piece of wood in the bottle resting diagonally can help, although it is not essential if the bottle is not too wet.
As with any insect, the life cycle of a fruit fly is greatly influenced by temperature. As a rough guide if you increase the temperature by 10oC the growth rate doubles (so the next generation hatches in half the time). Anything from 10-30oC should give a successful culture of fruit flies.