PHILADELPHIA — Wade Miley was on a roll in July until he cooled off against the Phillies.

Domonic Brown homered, doubled and drove in three runs to lead Philadelphia to a 9-5 victory over the Diamondbacks on Friday night.

Miley (6-7) struggled for the first time this month, giving up six runs — five earned — and eight hits in five innings.

“I felt good. I just didn’t have it tonight,” he said.

Miley won his previous three outings while striking out 19 in 20⅔ innings with a 1.74 ERA. But the left-hander was off from the jump against the Phillies, and the five earned runs were the second-most he has allowed in a start this season.

“He wasn’t very good,” Diamondbacks manager Kirk Gibson said. “He didn’t have a good feel with his pitches.”

Alfredo Marte hit his first career homer, a grand slam, and Aaron Hill had three hits for Arizona.

“It was not a good game for us,” Gibson said.

Miley labored through a wild first when Philadelphia sent eight batters to the plate while taking a 2-0 lead on a bases-loaded walk to Carlos Ruiz and Brown’s groundout.

“Walking three guys in the first inning, it’s tough to come back from that,” Miley said.

It was 3-0 after the second, thanks to Chase Utley’s RBI single, and Philadelphia tacked on two more in the third on Darin Ruf’s sacrifice fly and Cody Asche’s RBI single.

“The game kind of got away in the third inning,” Miley said. “That was on me.”

The Phillies looked in complete control when Ruf doubled and scored in the fifth. But Phillies manager Sandberg elected to lift Kyle Kendrick with the bases loaded and two outs in the sixth, and it backfired.

Marte cleared the wall in left, his first homer in 68 career at-bats, to make it 6-4.