fares_ibrahim's avatar

frameworks like laravel vs traditional php coding

maybe my question is tedious and trivial ...I'm learning laravel and i find it so cool ,,, to be honest i didn't program any website before from scratch using(pure php coding) my question here ... should i stick with laravel and made as many i could using it ,, or should i do before that some websites using(pure coding) or that will be reinvent the wheel !!

could you guys put down the cons and pros for both (laravel and pure php coding)

0 likes
12 replies
bobbybouwmann's avatar

Well Laravel is just a framework. A framework gives you some tools and function to make it easier for yourself. For example the migrations, the database seeds, the form request classes and so on. They make it easier for you do to stuff that you have to programme yourself if you are not using a framework.

However behind each framework there is a philosophy and if you don't follow that philosophy you might have a hard time using a framework. For instance the facades in Laravel. Some developers call it static functions some don't even want to call it facades at all. You can use them or not, it's up to you.

So a framework helps you to get from A to Z in a much easier and structured way if you know the framework. However it's always good to know how PHP works without Laravel. Let's say you need to build a specific feature and that doesn't really require Laravel, just old school PHP. Now if you only know Laravel, you will have a hard time creating this stuff. It's always good to have a basic knowledge of a certain language. Most developers start creating some stuff for them self to learn the basic and then move on to a framework

jlrdw's avatar

Learn both, also learn stored procedures, you may get a job that requires that knowledge. And remember, not everyone on the forum has done real sites for large companies, so don't believe everything you get from forum, check it twice like on stackoverflow.

IsaacBen's avatar

It will be like reinventing the wheel. Companies use frameworks, if you're a freelancer you will also use frameworks to speed up the time. So doing all from scratch won't help you in finding a job as an employee and neither as a freelancer. With that said you should know PHP well to understand what is going on, but there is no need to start practicing it by building complex apps.

1 like
Snapey's avatar

suppose you wanted to build a cabinet. you consider the design, maybe draw a little sketch, go out and buy some wood. Pretty soon you realise that you will need a saw. You go to the store and consider all the saws available on the shelves. Being a newbie you might choose the wrong one. You go back home and start researching all the saw types and which one might be best for your use. You watch videos on YouTube about sawing techniques. You buy the saw.

Then next, a screwdriver, but which one? And so it goes on. Eventually you have a pile of tools and techniques and hopefully you remember that you were supposed to be building a cabinet.

Laravel is like a free multi-tool toolkit. You have the best tools for the job all packaged in a nice case. What is more occasionally the man from the store comes along and brings you a new one that has a few extra tools.

With the right tools at your disposal you can concentrate on making the cabinet. You would not be as skilled a craftsman that built his toolkit over a number of years, and even made his own tools some times.

The point is, you can get on with making the end product. You may not have the real low level understanding, but that will come as you tackle problems and challenges as you go along.

3 likes
michaeldyrynda's avatar

I think it's important that you have a sound understanding of PHP fundamentals, design patterns, practices and so on before undertaking to learn any framework. You need to learn to crawl before you can learn to walk.

Whilst diving straight into the framework might help you to get something built faster, will you really understand why you're doing some of the things you're doing? Will you know when you're implementing something in a sub-optimal way, or a way which will be hard to maintain/understand/change later on down the track?

Understanding why a framework does things the way it does - and why it makes certain design decisions over others - is something you'll have difficulty grasping if you don't have a sound understanding of the language, its constructs, and architecture first.

Of course, if you're willing to live with that, then there's no reason why you wouldn't jump into the framework and ship something. I myself did plain PHP for about six years before starting to look at and understand frameworks, and how I could leverage them with the knowledge I already had. I think it'll do you the world of good.

jekinney's avatar

Lots of great advice and opinions.

My 2 cents: first and foremost you should understand php. When you can go the the php Manuel (docs) and understand then your better then most. It's a good foundation.

A framework should be a collection of code that makes development easier by providing the basics that 99% of your project needs. Authentication, validation etc. Laravel as mvc also includes those extras like routing, mvc structure and so on. Laravel imo is one of the most flexible out there as you can code how you want and structure how you want. But with out php fundimentals your just going through the motions and never really learning what it is your doing.

Nothing says you can't learn php while using a framework, but the first time you hit a snag, remember you can and will need php core. Good example is the sync() method for syncing pivot table data for many to many relationships. It's a great helper but in the background it just two foreach loops. One to delete all the associated data and another to add the given relationship. Not complicated but a lot of devs think it's faster then doing a loop in your code. It's ultimately the same.

lindstrom's avatar

Good points, all. I'll add that when you're just starting out, it really doesn't matter. You have so much to learn it's ridiculous to think that the choices you make in the first few months of your education will matter in the long run. Laravel isn't some crazy domain specific language. It's PHP. If you're using Laravel, you're using PHP. Will you have to learn "pure" PHP? Most definitely and when you do need it, you'll know. And 9 times out of 10, someone has already had to solve the same problem and you'll be able to find answers and implementations online. At first, you'll copy/paste and be excited when you get something working, but in time you'll start solving your own problems and you'll be visiting Stackoverflow and these forums less and less. Things will start to click. All the babble about patterns, abstractions, intefaces, etc. will make sense. And, maybe, just maybe, one day you will stop trying to get the property of a non-object. Have fun!

4 likes
lifesound's avatar

This is a dilemma. Especially after hearing what Rasmus said . Now , I don't know how to go .. Laravel is a very powerful tool , but not as simple as something u made .

phpMick's avatar

I think If I had to write something form scratch now, the first thing I would do would be to pull in some packages.

Something for logging, auth, ORM etc and before you know it, you would be back with Laravel.

:-)

jessicabarnes's avatar

I personally consider popular frameworks are an overkill for the most project except when you are working on some big project that demands work of multiple developers. The major issue with a framework is it adds needless complexity to the project and that not only increases the development time but also will be problematic in maintenance phase as well. Despite its recent growth, Laravel is still behind PHP in all market share segments. With pure PHP, we still can make use of great object oriented paradigms such as MVC, front controller and so on...

Please or to participate in this conversation.