Low-cost transition metal phosphides have received widely attentions in the renewable energy application for their comparable catalytic activities and long-term stability. In this paper, bimetallic phosphide nanocages embedded in porous carbon are synthesized through a simple pyrolysis procedure. Firstly, NiFe Prussian blue analogues (PBA) nanocubes were deposited on melamine sponge and in situ etched into PBA nanocages with ammonia solution. Subsequently, the as-prepared PBA nanocages were calcined with phosphorus sources at 350 °C to obtain the final catalysts. Owing to 3D macroporous structure of nitrogen doped carbon substrates derived from melamine sponge, the resulted NiFeP [email protected] exhibits desirable activities and stability toward the OER in alkaline media. Specifically, only a small overpotential of 290 mV is required at a current density of 10 mA·cm−2, a Tafel slope of 46 mV·dec−1. Facile synthesis method and excellent electrocatalysis of NiFeP [email protected] make it a good candidate of catalyst in water splitting and metal-air batteries.