Seeking examples of good PHP code and architecture.
October 8, 2017 6:21 PM Subscribe
I've done a Google search and found lots of people asking for examples
of good PHP code, but the answers almost always recommend frameworks,
and sometimes libraries. I'm looking for examples of well-written, well-designed
code in PHP applications.
If I had my druthers, I'd prefer code that doesn't use a prefab framework at all,
but that's not necessary.
If I had my druthers, I'd prefer code that doesn't use a prefab framework at all,
but that's not necessary.
Best answer: I remember being fairly pleased at the architecture of Vanilla Forums, at minimum the system they use for plugins. It's apparently built on a framework named Garden. It's pretty much the only thing written in PHP that I currently use, as I still have flashbacks to old Drupal installations I used to maintain.
posted by Aleyn at 10:56 PM on October 8, 2017
posted by Aleyn at 10:56 PM on October 8, 2017
For whatever reason it seems that a lot of PHP applications, both poorly and well written, end up morphing into frameworks. Take Magento as one example. It's an application, but it's also a platform.
posted by wierdo at 3:42 AM on October 9, 2017
posted by wierdo at 3:42 AM on October 9, 2017
I was waiting to answer this to see what everyone else had to say first as I didn't really want to discourage you.
The short answer is - without a framework, a good php application doesn't really exist. To asterix's point, I'll bet dollars to donuts there's actually a nice custom framework in there. Some sort of abstracted, reusable way to handle all of the common application tasks (authentication, routing, templating, etc) is what a framework does.
I think the "gold standard" today (i'm waiting for the haters... come on!) are the Symfony components. Symfony the framework is built on these. Even Laravel, the most popular PHP framework today, uses some of these. You can build custom applications using just some of basic Symfony components -- and in fact, thats what Silex, the micro-framework from the same guy responsible for Symfony, is at it's heart.
What is it about a framework you're trying to avoid? There are several "micro" frameworks that just set up the basic scaffolding for you -- you definitely dont need to use the huge behemoths like Symfony, Zend or even Laravel if you don't want to.
If you want to see what good looks like though - check out both the Symfony and Lavarel *documentation*. They both do it better than just about anyone else. Some of the code is well written, some may be sub-optimal (every codebase has its stinkers) but what makes them extremely nice to work with are current, up to date, complete documentation.
posted by cgg at 7:51 AM on October 9, 2017
The short answer is - without a framework, a good php application doesn't really exist. To asterix's point, I'll bet dollars to donuts there's actually a nice custom framework in there. Some sort of abstracted, reusable way to handle all of the common application tasks (authentication, routing, templating, etc) is what a framework does.
I think the "gold standard" today (i'm waiting for the haters... come on!) are the Symfony components. Symfony the framework is built on these. Even Laravel, the most popular PHP framework today, uses some of these. You can build custom applications using just some of basic Symfony components -- and in fact, thats what Silex, the micro-framework from the same guy responsible for Symfony, is at it's heart.
What is it about a framework you're trying to avoid? There are several "micro" frameworks that just set up the basic scaffolding for you -- you definitely dont need to use the huge behemoths like Symfony, Zend or even Laravel if you don't want to.
If you want to see what good looks like though - check out both the Symfony and Lavarel *documentation*. They both do it better than just about anyone else. Some of the code is well written, some may be sub-optimal (every codebase has its stinkers) but what makes them extremely nice to work with are current, up to date, complete documentation.
posted by cgg at 7:51 AM on October 9, 2017
Best answer: I've been wading through Moodle's codebase for the past few weeks at work and have found it pretty well designed / built. As far as I can tell it's not using a prefab framework.
posted by mustardayonnaise at 10:35 AM on October 9, 2017
posted by mustardayonnaise at 10:35 AM on October 9, 2017
The short answer is - without a framework, a good php application doesn't really exist.
This. PHP features so many incredibly spectacular ways to shoot yourself in the foot that most any "framework-less" app either has a de facto framework built in, or is a disaster waiting to happen.
posted by neckro23 at 10:57 AM on October 9, 2017
This. PHP features so many incredibly spectacular ways to shoot yourself in the foot that most any "framework-less" app either has a de facto framework built in, or is a disaster waiting to happen.
posted by neckro23 at 10:57 AM on October 9, 2017
Response by poster: Um, I'm not sure why so many people are assuming I'm looking for non-framework PHP examples because I haven't explored the alternatives. I have looked at code in other languages, I have looked at code for PHP frameworks,
I'm looking for something specific now.
cgg, neckro23: I specifically said "prefab" framework. Maybe my meaning was unclear? A "custom" or "de facto" framework isn't a prefab framework.
posted by lore at 12:00 PM on October 9, 2017
I'm looking for something specific now.
cgg, neckro23: I specifically said "prefab" framework. Maybe my meaning was unclear? A "custom" or "de facto" framework isn't a prefab framework.
posted by lore at 12:00 PM on October 9, 2017
« Older Gluten-free, dairy-free teff-based pie dough hack? | If I can only go to one Chicago restaurant - which... Newer »
This thread is closed to new comments.
To the OP: I'm not sure what exactly you're looking for that's PHP-specific. The principles that made the codebase I worked in a good one had nothing to do with the language; they were general ones that would have applied to Python or Ruby or any other C-based programming language.
posted by asterix at 9:54 PM on October 8, 2017 [1 favorite]