Sanheim, 23, is coming off his entry-level contract and was set to become a restricted free agent on July 1.
“We are very pleased with the progress Travis has made in his young career,” Flyers GM Chuck Fletcher said in a statement Monday. “He is a skilled, two-way defenceman with excellent size and mobility. He is a big part of our present and our future.”
Sanheim appeared in all 82 games for the Flyers last season, scoring nine goals and 35 points. Philadelphia selected him in the first round of the 2014 NHL Draft.
Sanheim said in a statement that he was pleased with the new deal.
“I’m looking forward to another two years with the Flyers. I’m really excited with the way the team’s moving forward and the moves we’ve made this summer.”