Is there a way to get a pallate of 50 or so fairly unique (to perception)
colors?
50 is tricky
The usual trick is to dive into the theory of the "colour wheel" and
to select a number of colours that are equally spaced radially around
a hue wheel, but are otherwise comparable in brightness and
saturation. This is a good technique for selecting a "handful" (i.e.
up to around 7) colours that are pleasing in combination.
For more than this, it's usual to look at rings on the same hue wheel,
i.e. splitting a previous "mid forest green" into standard, light and
dark variants. That could give you 21 or 30 without much trouble. This
is (IMHE) about as far as you can get for colours that are
recognisable enough to be identifiable between an information graphic
and a key list at the side. You can go for more than this by closer
spacing, you might even still have colours that are distinguishable
when adjacent (your main requirement here), but I doubt they'd still
be recognisable from one side of the page to another.
A useful technique is to select the colours with some intelligence,
not just randomly, and to ensure through your code that "close"
colours simply don't appear next to each other.
One approach that _doesn't_ work is to space colours out using their
RGB components. This is easy, but it's not how perception works and so
the results are very poor. Use HSV instead. I'm not familiar with PHP
for this, but HSV -> RGB conversion functions will either be supported
already, or are standard formulae.