This paper presents a total phosphorus online real-time monitoring system integrated with on-chip digestion based on the merits of optofluidic technology. The integrated optofluidic device contains a hollow optical fiber employed for pretreatment and digestion of phosphorus solution samples, a polydimethylsiloxane (PDMS)-based micromixer with convergent–divergent walls designed to enable sufficient mixing and chromogenic reaction, and a couple of optical fiber collimators attached with a Z-shaped flow cell for optical detection. Details of system design and fabrication are introduced in this paper. In the experiment, on-chip digestion of four typical phosphates in aqueous solution including organophosphorus and inorganic phosphorus is investigated under different reaction conditions, such as digestion temperature, concentration of oxidant and pH value, and the optimal reaction parameters are explored under different conditions. Meanwhile, we demonstrate the online real-time monitoring function of the optofluidic device, and the digestion mechanisms of four different phosphates are analyzed and discussed. Compared with the national standard method, we find that the measurement accuracy and sensitivity are acceptable when the concentration of total phosphorus is between 0.005–0.9 mg/L (by weight of P) in aqueous solution, which covers the range defined in the national standard. The traditional digestion time of several hours is greatly reduced to less than 10 s, and the content of total phosphorus can be obtained in a few minutes. The integrated optofluidic device can significantly shorten the test time and reduce the sample amount, and also provides a versatile platform for the real-time detection and analysis of many biochemical samples.