4 ms·
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 co
by krapp 12y ago
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.