The interaction of light with nanostructured materials provides exciting new opportunities for investigating classical wave analogies of quantum phenomena. A topic of particular interest forms the interplay between wave physics and chaos in systems where a small perturbation can drive the behavior from the classical to chaotic regime. Here, we report an all-optical laser-driven transition from order to chaos in integrated chips on a silicon photonics platform. A square photonic crystal microcavity at telecom wavelengths is tuned from an ordered into a chaotic regime through a perturbation induced by ultrafast laser pulses in the ultraviolet range. The chaotic dynamics of weak probe pulses in the near infrared is characterized for different pump-probe delay times and at various positions in the cavity, with high spatial accuracy. Our experimental analysis, confirmed by numerical modelling based on random matrices, demonstrates that nonlinear optics can be used to control reversibly the chaotic behavior of light in optical resonators.