Evan Mathis says he was close to joining another team.

Before re-signing with the Philadelphia Eagles on Saturday, he spent two days visiting the Baltimore Ravens.

"It was kind of close," Mathis said Monday in quotes provided by the Eagles. "I was kind of the hostage in the castle for a couple of days. (Ravens general manager) Ozzie Newsome has built some incredible teams over the years. When it came down to it, it was kind of close, but my heart was just here."

Mathis signed a five-year deal for $25 million, including $7 million guaranteed. He became the fourth player from last season's Eagles to either sign a new contract or an extension in the last week, following defensive end Trent Cole, defensive tackle Antonio Dixon, tackle Todd Herremans and wide receiver DeSean Jackson.

The Eagles also added depth to their offensive line Monday by signing free agents Mike Gibson and Steve Vallos. Gibson, who was an Eagles sixth-round draft pick in 2008, spent the past three seasons with Seattle. Vallos has played with Seattle (2008-09) and Cleveland (2010-11). Both are interior linemen who will compete for backup roles behind Mathis, guard Danny Watkins and center Jason Kelce.

Bringing Mathis back means the starting offensive line from last season could remain intact for the next few seasons. All five starters - Herremans, Kelce, Mathis, tackle Jason Peters and Watkins - are signed through at least 2014.

They also will get another year to work with renowned offensive line coach Howard Mudd, who joined the Eagles last season.

"I texted Howard and apologized for him being stuck with me for a few more years," Mathis said. "He was a huge factor in me coming back (to the Eagles). That's why I signed here last year. I knew his history and I knew he was one of the best offensive line coaches in the history of the game. If he couldn't take my game to the next level, then it wasn't meant for me to succeed in this league."

Mathis, 30, hadn't enjoyed much success until last season. The 6-foot-5, 302-pounder bounced around the NFL for six seasons, playing for Carolina (2005-07), Miami (2008) and Cincinnati (2008-10).

He flourished under Mudd. Mathis won a starting job in the preseason and wound up starting 15 games. He played well enough that he was considered one of the top guards on the free agent market, along with Carl Nicks and Ben Grubbs.

The Ravens were interested in having Mathis replace Grubbs, who signed with New Orleans.

Eagles general manager Howie Roseman told Mathis the team wanted him back but understood that he wanted to test the open market.

"That's the danger of free agency," Roseman said last week at the NovaCare Complex. "It's a big-boy sport and you run that risk when players get to free agency that you're going to lose them. We hope Evan Mathis remains an Eagle, but when you're on the open market, things happen."

Mathis said he didn't get much attention when free agency began last Tuesday but flew from his offseason home in Arizona to Baltimore to meet with Newsome last Thursday and Friday.

Once the Eagles learned that the Ravens were interested, they made their pitch.

"Howie played it really smart," Mathis said. "He was kind of like waiting on eBay until the last second so that he didn't bid the price up. I'm really lucky that the Ravens got in it so I could get the contract to a decent level."

Contact David Weinberg: