

Php - johna123

Advantages&#x2F;disadvantages between building pure PHP vs. a MVC PHP Framework?
======
krapp
The advantages to using a framework in PHP are the same as using a framework
in any other language. You're provided with a set of abstractions which make
the code easier to reason about, and deal with in a modular fashion.

Having written raw PHP where you have to manually include libraries and have
to manually escape everything that gets echoed to the browser, and having also
worked with frameworks, I find the benefits of having a PSR compliant
autoloader and Composer to deal with dependency management, and a sane
templating library to separate the concerns of data and presentation, make it
much easier, and faster, to get a site up and running with less time wasted
reinventing the wheel, and greater confidence in the general safety of the
code.

Raw PHP, while tempting, can very easisly encourage poor design practices, and
lead to spaghetti code which is a nightmare to maintain.

Disadvantages to a framework would be, to take full advantage of it, you have
to couple your code to the framework. Eventually frameworks go out of fashion,
may cease to be updated, and may no longer have a decent development pool to
draw from. Also, frameworks simply by having more code to run between requests
are slower than raw PHP, but frameworks can also mitigate this by caching,
generating optimized classes, and whatnot.

But of course, you can pick a microframework like Slim and have the advantages
of both if you want. But the way I see it, with anything beyond a basic site,
you're going to wind up with something resembling a framework anyway.

------
LarryMade2
Well a framework has done all the heavy listing, you add in your stuff and can
be good to go in an extremely short time. Drawbacks are you are married to the
framework, have to keep it updated as well as live with its idiosyncrasies and
quirks (sometimes you just cant easily do something in a framework and have to
kludge it in..., and it will probably get worse as time goes on). Another fear
is that the framework may end-of-life or go through some massive refactor at
sometime and you would have to re-configure to project to keep going.

Pure PHP is good but takes time to develop code to something mature, you will
get maximum flexibility (you will eventually get what you want), but you are
dependent on your skills and research. Pure PHP can be safe, just you have to
research and implement whatever safe code/practices you need.

Kind of depends on what you are going for. If you want to fiddle, try both. If
you want something that would be complex quick, probably a framework. If you
want something that you can't see done with a framework and are willing to put
in the time and effort, pure PHP would be a good route.

I read if it is short term good to go with a framework, long term, you should
expect to end-up with something more robust (start with framework, build into
a more stable long term pure PHP for the long haul).

------
sherizan
Thought about that but found Codeigniter to be extremely powerful yet
lightweight. Managed to do URI routing easily, got my db/functions into Model
working fine and everything is clean and reusable. Other frameworks looked too
bulky. Not quite sure if pure PHP is safe. You might spend a lot of time
securing it. Then there are also issues with caching and shit.

