We propose two compact, economic, and scalable schemes for implementing optical controlled-phase-flip and controlled-controlled-phase-flip gates by using the input-output process of a single-sided cavity strongly coupled to a single nitrogen-vacancy-center defect in diamond. Additional photonic qubits, necessary for procedures based on the parity-check measurement or controlled-path and merging gates, are not employed in our schemes. In the controlled-path gate, the paths of the target photon are conditionally controlled by the control photon, and these two paths can be merged back into one by using a merging gate. Only one half-wave plate is employed in our scheme for the controlled-phase-flip gate. Compared with the conventional synthesis procedures for constructing a controlled-controlled-phase-flip gate, the cost of which is two controlled-path gates and two merging gates, or six controlled-NOT gates, our scheme is more compact and simpler. Our schemes could be performed with a high fidelity and high efficiency with current achievable experimental techniques.