We measure the transport properties of mechanically strained single crystals of BaFe₂(As₁₋xPx)₂ over a wide range of x. The Neel transition is extremely sensitive to stress and this sensitivity increases as optimal doping is approached (doping with the highest superconducting Tc), even though the magnetic transition itself is strongly suppressed. Furthermore, we observe significant changes in the superconducting transition temperature with applied strain, which mirror changes in the composition x. These experiments are a direct illustration of the intimate coupling between different degrees of freedom in iron-based superconductors, revealing the importance of magnetoelastic coupling to the magnetic and superconducting transition temperatures.