I'm planning to go in mid-July, the cost of air travel is quite high so I'm looking for alternatives.
What are the train networks like through France/Spain/Portugal? How long would it take and how much will it cost?
How high is "high"? Poking around on Ryanair, I can see fares of eg. 49 GBP all in for Stansted to Porto on July 13, and it's a 3-hour train ride from there to Lisbon. I don't think there's any way you can get there even nearly as cheaply by train alone, but if you want to try, Seat 61 lists out the options:
Based on the prices there, it looks like London-Paris-Irun-Lisbon would set you back a minimum of 150 quid even with cheap advance fares.
As mentioned, the Seat 61 Portugal page has most of the options for travelling there by train. Booking in advance, you can get it to be fairly cheap, but not as cheap as many of the budget airlines go. However, one thing in favour of the train is that bookings generally open 90 days before travel. So, if the cheap flights have sold out (which often go on sale 1 year in advance), but it's just over 3 months until you want to travel, you could hold on a little bit and try to get the cheap advanced purchase tickets on the day they go on sale.
Another option is to take the ferry to Spain, then train, but that's coming in even higher, unless you can get an unusually cheap ferry deal (unlikely during peak season)
One other option is to take the bus. Eurolines, for example, run buses through to Lisbon. In their winter timetable, they have 3 buses a week to Lisbon, for ~£100 one way or ~£165 return. I expect it'll be a little more in summer, but that is less than the advanced purchase train tickets. However, it does mean spending 36 hours pretty much non-stop on buses...