The evolution of bosons undergoing arbitrary linear unitary transformations quickly becomes hard to predict using classical computers as we increase the number of particles and modes. Photons propagating in a multiport interferometer naturally solve this so-called boson sampling problem, thereby motivating the development of technologies that enable precise control of multiphoton interference in large interferometers. Here, we use novel three-dimensional manufacturing techniques to achieve simultaneous control of all the parameters describing an arbitrary interferometer. We implement a small instance of the boson sampling problem by studying three-photon interference in a five-mode integrated interferometer, confirming the quantum-mechanical predictions. Scaled-up versions of this set-up are a promising way to demonstrate the computational advantage of quantum systems over classical computers. The possibility of implementing arbitrary linear-optical interferometers may also find applications in high-precision measurements and quantum communication.