Category: PHP

Quite a while ago I have implemented something called RouteBuilder(has been renamed to ViewBuider in the meantime) in Sulu, which - as the name suggests - makes use of the Builder pattern in order to create different routes in a Sulu application. In addition to the Builder pattern the Factory pattern was also used.

And the best thing is that the getRoute method of both builders still return a Route object, so we can still easily iterate over all available routes, and know how to handle them.

Another advantage is that the Builder object can also be passed as argument to other functions taking part in the object creation process.

Usually is said that the Builder pattern is great when you want to create an object in multiple steps.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners