Let's build PHP pagination from scratch, creating an algorithm to build page links, and a formatter to transform links into an HTML view.