Being a software developer, I just want to share how awesome and beautiful having the job of communicating with a computer and telling them what to do as you please. Not to mention, the ever so demanding clients and end users who are sometimes hard to understand and a pain in the-ass in conveying their language on what they want for their project.
Way back during my college days I never had the time to explore these so called “Frameworks”. I use to grind with the old fashion way of coding and that is by scratch. Each line of code has to be meticulously coded line per line without the aid of built-in functions or libraries.
Fast forward today, I have played with different types of frameworks and perhaps by far one of the best Frameworks that I have tried would have to Laravel.
But first why Laravel? You might be asking why I chose Laravel over a bunch of frameworks and may think I’m biased over it. Actually, Laravel is the culmination of the best web technologies all bundled in one. (And yes I am biased 🙂 so bear with me.)
First of all you have to ask yourself, am I ready to handle frameworks? Will it be hard? I have talked to different programmers on their views with regards to different type of frameworks. And I am not surprised, they do have their own choices and why others still prefer the old method of creating code by scratch.
What is a Framework?
A framework is actually a support system, or a development tool in developing web applications or any programs that you would like. Frameworks are associated to perform different type of activities and help developers such as yourself to build applications rapidly.
To make it less technical, consider a framework as a house. A house cannot stand itself without a supporting structure. Like steel bars, cement, wood, gravel and other construction supplies that are essential to create the f
oundation of the building. Think of an empty house. The house empty, but it already has some rooms, a toilet, a swimming pool (if it is expensive, yeah right!), a terrace,a front yard and etc. You cannot sleep in it yet because it doesn’t have a bed, nor cook food since there isn’t a single appliance that you can find in your empty home.
However, you don’t have to worry about constructing the house since it is already there. And all you have to do is to decorate it like painting it, or buying some appliance to make it “livable” and usable.
Since you are already using a framework, you are no longer have to worry about anything like building a new room or laying down some pipes from the main sewage to your toilet. As the framework already has got you covered with all of the dirty work.
Compared from building from scratch, it is like building a new house, with your design. You have to follow your own set of blueprints like creating your own classes in which will take a long time. In the case of a framework everything is already laid-out and it is easy for you to apply your code with ease. Without having to worry about other stuff.
And lastly, Frameworks are trusted by the community, it is constantly tested every day for bugs by the community. (Yeah, they even resurrected CodeIgniter for being dormant for one year. That was my first love sigh)
Why a Framework?
Same as in the real world. Why construct a house when you can buy an already built house (Just for the sake of explanation, although some still prefer to construct their own house 🙂 with all those fancy customization and stuff. But then again you can still customize in your framework. That is what we call as API’s or custom classes. We will discuss it on the next chapter ).
Frameworks typically follow a pattern. And in this case PHP frameworks follow the MVC pattern. What is MVC? It is simply known as Model-View-Controller. An architectural pattern that separates the logic from the view and data.
- A Controller sends a command to update a model state. Usually, these functions are associated to change the view, or presentation of a document. Consider it as the brain where all of the logic’s are place in which it manipulates data.
- The Model is usually manipulates and typically you can find them in database interactions. It also represents data or some sort of activity.
- The View is what the user see. And they usually request information from the model to generate the output that will be represented back to the user.
From the house example, the view is like the façade (some french word I borrowed) of the house or the physical appearance of an object. It is what the people outside see. The color, shape and aesthetics of your house. The controller on the other hand are the door, windows, and appliances of your house. You open a door to get inside the house, sleep in the bed or cook food in the oven. While the model is the product that you interact with the objects of the house. Like cooking (controller) food(model) inside the oven. In which, when the food is cooked, you will be notified by an alarm or blinking lights(View) that indicate it is done.
I hope you get the idea how frameworks work and how they can easily help you with your own project. Sorry for the long post, but I just have to make it as simple as possible and using real-life objects will be handy enough to make it easier for you to understand. Take a deep breath, and start using Frameworks young Padawan.
In my next post I will be teach you how to install Laravel on your PC and start programming the eloquent way. (pun intended)