First choice, hands down, is a real fence. 48" field wire at Tractor Supply is cheap and always held my dogs in Florida. You can fence acreage with it and not run yourself into debt for the rest of your life.
Second choice, invisible fence. Because let's be real...the average pet owner is not looking all the time and isn't going to give a consistent warning and consistent correction with a remote collar, so they need the system that will do it for them. I hate invisible fences, for the record. To try and do this with an e collar, and then occasionally not be ready, not be looking, or not be there, is going to make the dog gamble about testing the boundary which means he is less safe and getting shocked more.
Hence, third choice, train by hand with remote collar.
I did do it with my dogs in our first house in Florida. We had a small backyard fenced, no fence in front and going and coming from car to house became a problem when a puppy moved in across the street that my dog wanted to run and play with. Both dogs blew us off to run see each other. The puppy got an invisible fence, I got an e collar. I did not boundary train with it, though, I only proofed the recall. Problem solved.
It's worth mentioning the end of that story was that the puppy across the street was not properly trained on her invisible fence and ran through it to get to my house because she wanted to move in with us. Apparently my dogs told her what it was like at my house. She then would not go home, because she would not cross that boundary just to go back and get yelled at, I had to take her shock collar off and physically drag her back onto her own property every time she ran over to my house. Part of why I hate invisible fences.