John Anderson said the alleged ordeal also had him screaming for his life after a young boy was ordered to light his petrol soaked body.
Jurors heard claims the 43 year-old had earlier fled from a member of a traveller family he was working for.
He escaped from James McPhee and left Scotland for Oxfordshire.
But Mr Anderson was found and returned north where he was then allegedly battered and “taught a lesson” by McPhee’s father Robert.
Mr Anderson said he was later dumped in the metal shed where children also apparently came in and urinated on him.
He was today giving evidence at the trial of James McPhee (45), Robert McPhee (65), Steven McPhee (37) and John Miller (38).
The four face a total of 30 charges between them at the High Court in Glasgow.
The accusations, which span from 1992 to 2016, included slavery and violence.
The four denied the allegations.
Mr Anderson had been homeless in 1998 when he was offered labouring work by James McPhee.
He stayed on a caravan site and carried out jobs such as mono-blocking driveways.
But the man told how McPhee could be violent towards him “whenever he was unhappy”.
The alleged assaults including being punched, kicked and hit with a pick axe handle.
Mr Anderson said he was “scared” to leave, but went with another worker to a house in Paisley, Renfrewshire.
The trial heard James and his brother Steven McPhee found him despite trying to hide in a wardrobe.
He was taken to a site in Bathgate, West Lothian.
However, Mr Anderson later left again – this time with a fellow worker heading for England.
The men managed to “skip” a train without paying to Berwick before they got a lift from a trucker to Banbury in Oxfordshire.
Mr Anderson initially got a barman’s job, but then got a word that someone had come to the house he had been staying at.
He recalled: “I left the pub because I was scared of getting found by James McPhee.
“I walked along the canal the whole day ... the intention was just to get away. I was terrified.
“I found a yard that had a static caravan and slept there for the night.”
Mr Anderson briefly returned to Banbury to collect his wages before going to a homeless shelter in Cambridge.
He told how he met a fellow Scot there and he offered to buy him a pint at a local pub.
Mr Anderson said he was left in “shock” when James McPhee walked in.
The witness told the jury: “He knew that I was there because the boy (Mr Anderson was with) had taken a picture of me and sent it to him.”
Mr Anderson said he was “scared”, but left for Scotland in McPhee’s Mercedes four-wheel drive.
He recalled they ended up in Larkhall, Lanarkshire, where McPhee lived.
Mr Anderson said it was there he was taken into his house and Robert McPhee – nicknamed the Tank Commander – was also inside.
The witness saud: “James told me that it was time to meet his dad. I knew what he meant. I was to get a beating.”
Mr Anderson said he was to be “taught a lesson” not to “run away” again.
He described how he was allegedly attacked in the kitchen by Robert McPhee – known as Bobby - and ended up grounded.
The man said he was punched “all over”, hit with a broom and kicked.
Mr Anderson then told how he ended up being put in a metal shed where a dog slept.
He remembered it being winter, but he was told to strip, had his hands and feet tied with rope and was left inside.
The court heard James McPhee came the next morning with a young child.
Mr Anderson recalled feeling “cold, sore, tired and desperate”.
The court heard the man had no food or water.
Mr Anderson told jurors: “James asked was I hungry? He said that if I was hungry enough, I could eat the dog food.
“I did not get any water.”
The trial heard Mr Anderson also had petrol poured over him from “head to toe”.
The witness went on: “He told the boy to light the lighter and burn me.
“The boy lit it and came towards me. I was hysterical. I thought he was going to set fire to me.
“I pleaded ‘don’t do it’. I said ‘I won’t do it again. I have learned my lesson’.”
Mr Anderson was not set alight before McPhee and the child left.
Prosecutor Kath Harper asked: “What were you feeling at that stage?”
He replied: “I wished he had lit it.”
Mr Anderson recalled two children also coming to the shed and urinating on him.
He remembered the youngsters “being under 10”.
The trial, before Lady Stacey, continues.