You break down with hopelessness and despair
Every time you read about PHP frameworks you cry with frustration! Your brain melts with utter confusion. You shrink into the corner feeling completely intimidated!
One time, you even felt brave enough to download a framework. But, you had no idea what the hell to do with it next.
You see people mentioning frameworks all the time on forums, but you also see all the confusion around them. Heck, there is so much misdirection. So much clutter. So much point-scoring over which framework to use that the whole point of a PHP framework has bypassed you completely. You feel like they are a mountain to climb – and you just don’t have the time right now for pursuing extreme outdoor sports. Time is money you know!
It doesn’t have to be like that
Just imagine for a moment… What if PHP frameworks were your area of expertise? What if you approached them with confidence, certainty and skill?
What if you based your decision to use a PHP framework for your next project on your complete understanding and knowledge. What if you could easily and expertly apply what you have learned in one framework to any other framework out there?
You can become an expert
Start right now! Take take your first steps into the world of PHP frameworks. My series of easy to read and understand articles will guide you. And the best thing – they are completely FREE!
Article 1 starts here!
Let’s get going! Let’s find out what all this PHP framework stuff is all about.
What exactly is a PHP Framework?
There is so much confusion over frameworks that you are be forgiven for not having the first clue! And even if you do have an inkling, there is such a mass of discussion on the forums about what frameworks are, what the benefits are, which framework to use and whether they are just libraries or not… the level of confusion and contradictory messages is quite overwhelming.
But you can relax. Take a load off and together we’ll cut through the intimidating technical jargon and simplify everything a bit. So turn the lights down low and snuggle up…
Why a framework?
Before we get into what a framework actually is, you may find it easier to approach things from a different angle. Lets first look at some of the problems and pain points that frameworks are supposed to solve.
“I don’t want to have to re-write the same code time and again, I feel like I am just re-inventing the wheel!”
“Arghhh, this code is like a big pile of spaghetti! How am I supposed to do anything with it?”
“I am so scared of writing a PHP app and messing something up, especially security – what if someone hacks my site?”
“Coding standards? Erm, are there such things as coding standards?”
There are a ton of other issues as well, but I’m sure you get the idea. Frameworks in all languages attempt to instil a set way of putting something together (a website, app etc), because (we hope) that the “set way” has been proven to be the best. But what does “best” mean?
In our world of web apps and websites, “best” is generally accepted to mean:
- Bug-free (or bug-reduced at least)
- Well supported
Most of us would like to add simple, easy to learn and easy to implement to that list as well. However, we also have to accept that there is a learning curve to anything that ultimately makes things easy (oh the irony!). But thats a subject for a different article.
Back to it
So now you know what challenges a framework is designed to solve, and that its chief aim is to provide an environment that encourages “best practice”. Does that get us any closer to finding out what a framework actually is?
Well, yes and no. Yes because we know it is an environment. No because so is coding raw PHP in an IDE without a framework – albeit akin to a plate of your finest Italian stringy pasta at times.
Yes because we are now getting the feeling that it has constraints. No because that doesn’t really tell us anything!
You are starting to lose me!
OK, some definitions of a PHP framework that are found in a web search:
“Essentially a framework is the structure that you can choose to build your program on”
“Frameworks provide scaffolding that can allow you to develop faster/more cleanly”
“A PHP Framework in my eyes is a collection of classes which help you develop a web application”
The one I like the best is the one referring to “scaffolding”. Further to this, I see a framework as an environment that provides the core foundation and plumbing for your application.
There is quite a lot of discussion about the collection of classes train of thought, and although in some respects that is true, it is only part of what a framework is.
Maybe we’re asking the wrong question by asking “what is a PHP framework?”. Perhaps it is just too fuzzy a concept to put a concrete definition on. Perhaps a better starting question is “what can a framework do for me?”
So, what can it do?
This again can be quite hard to answer in concrete terms, and can also become quite personal. But, in simple terms a PHP framework can greatly speed up the development of your web application by doing a lot of the grunt work for you.
Aspects where you would normally have to re-write code time and again, such as connections to databases and form validation, are all usually part of the framework. You just put in the correct configuration and away you go.
OK, not quite, but you certainly don’t need to be starting from scratch every time. In fact, many frameworks include CRUD creation. CRUD stands for Create, Read, Update, Delete and is to do with the interaction with the database. A CRUD generator will take your setup and literally generate the underlying code to perform most of the interactions you need to read, write and delete data.
Frameworks also offer many other benefits such as site security, separation of PHP code from HTML (therefore encouraging best practice and easier bug-tracking), and easier future maintenance.
I’m scared I’ll lose control!
One recurring theme I see on the forums when people are trying to decide whether to learn a framework or not, is the fear that they will lose control of their code. Although really out of the scope of this article, I felt it important enough to address it here.
The people I see making these comments don’t fully trust somebody else’s code, even if that somebody else is an entire community of developers who have spent the last few years testing and improving the underlying design and coding base.
You may have heard of the term “Not Invented Here”. In fact, many refer to it as a syndrome. The “Not Invented Here” syndrome sufferers are those that simply don’t want to put trust in the work of others. Usually, this stems from this fear of losing control and is the exact opposite of “invented Here” or “Proudly Found Elsewhere”.
When time is money and you are running your own business writing websites or developing web applications (or your boss is breathing down your neck on your latest project), I don’t believe you can afford to take the “Not Invented Here” approach.
Of course, you should have the underlying core skills and carefully select the framework you do use, but to take a purist stance on this is only hurting your financial health.
That’s all I’ll say on this for now, but if you fit into this group of people then perhaps you should really look at how much maintaining this attitude is actually costing you.
There are many benefits to PHP frameworks that we’ll cover in future articles, but for now let’s summarise what we already know.
- A PHP framework is a structured development environment designed to encourage best practice.
- A PHP framework provides the core foundation and plumbing to perform many of the functions you usually want to do with your web app or website.
- By creating a usable, secure and largely reliable scaffold, the speed and ease with which you can develop your site or app is greatly increased.
- As a small business owner, using a PHP framework can shorten the time to completion and therefore increase your profit and/or help you to become more competitive.
- As an employed developer, a framework can make your job a whole lot easier by removing the need to continuously re-invent the wheel.
Now that we are getting a good grounding of what a PHP framework is and some ideas on how it can help us, we need to look at one of the most confusing areas for a lot of people: the structure of a PHP framework.
This is the subject of my next article on PHP frameworks, which is coming very soon.
To get more of your questions answered, sign up to my newsletter now! Make sure you get all the latest PHP tips and tricks delivered directly to your inbox: