I've almost been in your shoes. I wasn't thrown out of a PhD, but I was on the verge of failing one: Having difficulty focusing on work; not making any progress on anything for more than a year; watching my colleagues advance, sometimes brilliantly, even though I did not consider myself inferior to them intellectually. Even later in life - I've felt my post-doctoral stint was semi-squandered, not having been able to put papers in places I wanted, or needed, to put them in. I also struggled, initially, to find work coming out of Academia.
And throughout some of those years I was also struggling with depression, anxiety, and the sense that that's it - I've blown my chance in life; I've let myself down, as well as the expectations of others.
... so, were you thinking I was going to tell you how I've overcome adversity and gone on to flourish and succeed? Eh. Maybe. But I don't want to sell you that. Instead, it's a matter of being able to cope with failure - which is very difficult for those of us that are used to things going our way in life.
Here's some of what I did that helped me (or didn't do initially, and regretted it later); not in order of significance:
- Not-super-strenous aerobic physical exercise (walks outside, yoga, possibly jogging or other stuff). Definitely helps emotional stability and the sense that living is worth it even when you're just, you know, living. (Yes, do this even at the expense of time available for research / job search / etc.)
- Keep in touch with friends and family (but with those who are supportive rather than overbearing and order you around). Try not to maneuver yourself to be alone all the time. (Yes, even at the expense of time available for research / job search / etc.)
- Make a conscious effort to sleep enough hours a night (if you can help it, that is).
- Get recommendations for a psychotherapist, if you can afford one, or see some kind of "social worker" if you can't. This depends on there being some sort of health care system available or you having the money.
- Consult your doctor (your GP) about possibly going on anti-depressant medication. This is not an easy choice to make, since doing so feels like admitting failure, that you can't "handle it on your own"; or that it's a sort of an embarrassing crutch. But if you get professional advice to use an anti-depressant, remember that crutches help people get back up on their feet while they heal; the same may be true for you. Caveat: There are different kinds of anti-depressants; their effect is not uniform on everyone; some have adjustment periods; don't just take something without medical oversight.
- Find something (or several things) to work on that's independent of being employed or in academia. It could be a social/community cause; a hobby; a free software project; some sort of construction work; etc. Even though this will not be ultimate purpose of your life, it helps to have something to look forward to and plan ahead for, rather than the major stuff that's not working out right now.
I realize some of these suggestions sound trite, or cliché; but frankly - so is your situation. What you're describing happens, with some variation, to lots of people (well, "lots" relatively to the small number of PhD candidates of course). Do some of what I've suggested, and you'll pull through, like almost all of them. Of us.
PS - I haven't given any "career-wise" advice. It's not that I think this is unimportant, I just focused on your emotional well-being in the here and now. A longer answer than mine could have been in order here.