Introduction to Frameworks
Hey everyone! For the dev dive today, I want to talk about frameworks. Writing a complicated piece of software often means implementing functions that already exists elsewhere, which in a lot of cases would be a waste of time. After all, there’s no need to reinvent the wheel. This is where frameworks help us out – they provide a pre-built foundation for certain parts of a platform that can be built upon.
A framework is, in essence, a set of code that implements some kind of common functionality. You can think of building software kind of like making a lasagna – if you were to code everything from scratch, it would mean making your own tomato sauce, pasta, bechamel, ricotta, etc. Using a framework would be like buying all of those ingredients pre-made, allowing us to just assemble them all at the end. A good example that we use at Punchmark is called Bootstrap. Bootstrap is a framework for the front end – it gives us tools for creating designs in code that would be much more time-consuming to create otherwise.
One of the biggest things that Bootstrap does is to automatically section a webpage into 12 equally sized columns (you can see this when editing columns using PageBuilder 2). Elements can span across any number of these columns, but they’ll automatically snap to the edges of however many columns are specified. This means that as a page is resized, the layout and design of a page can resize dynamically with it. In addition, Bootstrap will let you choose how to display an element based on whether the page is being viewed on desktop, tablet, or mobile, making it much easier to create a responsive interface.
Bootstrap also gives us pre-made UI elements with a lot of built-in functionality. Dropdowns that allow search and selecting multiple options are as easy as adding a couple of words to the element’s tag. A lot of the data tables in SiteManager are built with Bootstrap as well – functions such as pagination, search, sorting, and more are all built in, meaning we don’t have to custom build every one of those functions for every page.
Frameworks also exist for back-end code. We tend not to use major back-end frameworks at Punchmark, since we’ve built most of our back end from scratch to better serve our own needs, but some popular PHP frameworks include Laravel, CodeIgniter, and Symfony. Frameworks like these can offer built-in session tools, cache, user authentication, and testing functionality.