Choose the interpolation space explicitly so the intermediate colors are reproducible:
use PhpColor\Color\Color;
use PhpColor\Color\Palette\ColorPalette;
$transition = ColorPalette::interpolate(
Color::parse('#7c3aed'),
Color::parse('#f59e0b'),
steps: 7,
space: 'oklab',
);
assert([
'#7c3aed', '#8b59d7', '#9d6dbf', '#b17da6',
'#c78a88', '#dd9561', '#f59e0b',
] === $transition->toHex());
use PhpColor\Color\Color;
use PhpColor\Color\Palette\ColorPalette;
$transition = ColorPalette::interpolate(
Color::parse('#7c3aed'),
Color::parse('#f59e0b'),
steps: 7,
space: 'oklab',
);
assert([
'#7c3aed', '#8b59d7', '#9d6dbf', '#b17da6',
'#c78a88', '#dd9561', '#f59e0b',
] === $transition->toHex());
Both endpoints are included. The result is an unnamed ordered palette; name its positions separately if they become design tokens.
See palette interpolation or read interpolation and sampling.