Beginning Steps
Before beginning with the tutorial, there are some introductory steps that are necessary.
Installing the Slim Framework
To begin, make surethat you have the Slim framework installed. If you do not, installation instructions can be found here. Return to this page when this step is completed.
Important information to keep in mind
By this point you should have the Slim Framework installed. Before we continue, there are a couple things that are good practices to keep in mind moving forward.
First, when accessing a database, it is often frowned upon to sign in using the root user. Users rarely need all of the privelages that the root user offers so we often create user that have access to only what they need. We will go through steps to create a limited user with access to the database we create.
Second, there are many ways to actually store images using MySQL and the Slim Framework but one way that should generally be avoided is storing the actual image in a database through Binary Large Objects (BLOBs). This is usually considered bad practice. You are consuming connections to the database, that are going to remain open longer, that could otherwise go to something that should be in the database. Also, another problem with storing BLOBs in a database is the increase in size it is going to add to your backups. Should you have to do a restore, it is going to take a lot longer to load up that giant sql backup you've taken because it has been inflated with blob data. If you would like to know more, there are many responses to this question online. In this tutorial, we will be storing URLs in a database and then accessing that URL through PHP to display that image to the browser. The test URL (and image) we will be using is displayed below.
