Catalysis of the reaction: D-ribose 5-phosphate + D-glyceraldehyde 3-phosphate + L-glutamine = pyridoxal 5'-phosphate + L-glutamate + 3 H2O + phosphate. The reaction occurs in two steps: L-glutamine + H2O = L-glutamate + NH3, and subsequently D-ribose 5-phosphate + D-glyceraldehyde 3-phosphate + NH3 = pyridoxal 5'-phosphate + 4 H2O + phosphate.