Direct synthesis of phosphorus-doped graphitic carbon