Code for rotary encoders

Hi. Im new to arduino.
Can someone help me write a code for arduino uno, 8 rotary encoders and 2 shift registers?

So 4 rotary encoders to each shift register.

I will use more encoders if i can make these work.

Im using pcf8574t shift register
And Ec12e20 rotary encoders.

That's not a shift register, that's an I2C IO expander.

Here's what I use for reading encoders using an MCP23017, different IO expander chip, similar principle.