The 37-year-old Castro hit .277 with a homer and nine RBIs in 57 games for the Dodgers last season, making 19 starts at shortstop, eight at second base and two at third base, while also appearing in left field for two games.
The right-handed-hitting Castro batted .462 (6-for-13) against National League East teams in 2009.
"In Juan Castro, we have a versatile guy who can play multiple positions and is coming off a year in which he swung the bat fairly well," Phillies general manager Ruben Amaro Jr. said in a statement. "We're very happy to add him to our club, as he will give [manager] Charlie [Manuel] options."
Castro, a native of Mexico, sports a career .230 batting average in 15 seasons in the big leagues. He's made most of his appearances as a shortstop, but has seen ample playing time at second and third base.
On Thursday morning, MLB.com reported that the Phillies are closing in on a three-year deal with Placido Polanco to serve as their third baseman. Castro would join Greg Dobbs as a backup infielder.
Alden Gonzalez is a reporter for MLB.com. This story was not subject to the approval of Major League Baseball or its clubs.