The linear and nonlinear optical properties of two metalloporphyrin complexes formed by the complementary coordination of central zinc or magnesium ions to the ligand 5, 10, 15-tri-(p-tolyl)-20-phenylethynylporphyrin are theoretically investigated by using the analytic response theory at the density functional theory level. The results indicate that the studied complexes present more symmetric geometry structures than the ligand. The charge-transfer states of the two complexes in the lower energy region are all almost degenerate but those of the ligand are well separated. The ratio of the two-photon absorption cross sections of the ligand, zinc-porphyrin and magnesium-porphyrin complexes is 1.0:1.5:1.8, demonstrating that the two-photon absorption capability can be greatly increased when the ligand is coordinated with a metal ion. Moreover, several physical micro-mechanisms including electron transitions and intramolecular charge-transfer processes are discussed to explore the differences in optical property between the ligand and two complexes.