开发者

Drupal as framework

Can we use Drupal as a framework for larger application? Is it suitable开发者_运维技巧 for developing big application in its framework, or is there any limitation of it?

I want to use Drupal as a framework in my application. Is it worth?


If you are looking for a development-framework, Drupal is probably not the right choice. If you are looking for a suite to build websites, Drupal is probably the right tool.

People often tell that Drupal is a CMF, where the F stands for Framework, but in reality, Drupal is simply a flexible CMS.

On a high level, web application framework are split into two categories: the MVC and the CMS. Model View Controller being what most people call a framework. CMS being simply a flexible CMS with application-development abilities.

In practice, what Drupal lacks is:

  • Proper architecture. Most things in Drupal, evolved organically; which causes inconsistency, unexpected behaviour and unexpected barriers. Not saying that Drupal is not build up properly: just saying it has not been architectured: designed as a whole.
  • Principle of least surprise. Many frameworks allow skilled developers to create sites in a few hours. With Drupal you must gain a lot of experience and best-practices before you can be confident to roll out websites on planning.
  • MVC. Drupal has a distinct database-layer and a theme(view) layer, but they are unconventional, and often misused. And certainly not after a structural pattern.
  • unopinionated behaviour: a framework can force certain methodologies, libraries or even encourage certain behaviour, but it should not have hardcoded/none-overridable defaults that dicate your end-product. Or, in English: Drupals core has many defaults that dictate how you are going to set up, layout and structure your website, regardless of your (clients') needs or wishes. Modules or addons come even momre often with behaviour and often looks built-in and/or hardcoded.
  • DRY, don't repeat yourself: Drupal heavily depends on repeating oneself. Its entire theme-system depends on copying pieces of code into custom files and changing tidbits. Its form-override system requires copying large parts of the default form into custom modules and changing the parts that one wants modified.

Many of these lackings are the main cause for delay and budget-slips, as seen in my +10years Drupal-experience. Where the unopinionated behaviour part has proven the most nasty one to most of the projects I was involved in. Apparent simple features or ideas prove to take up large parts of the entire budget; Tiny details eating away development-weeks; that last 20% taking not just 80% of the effort, but sometimes 300%.

Besides that, Drupal does not follow OO patterns, which (according to the general consensus) is a bad thing. There is no inheritance, not DRY-practice, no object-relation-mapper*) and no unittesting-practice.**).

This might all sound negative, but in reality, people manage to build nice Drupalsites despite all these "downsides". That is because they adhere to the defaults by Drupal mostly (standard where possible, addons where changes wanted, custom development when no other option is left).

*) In fact there is; in Drupal 7, PDO was introduced, but is not (yet?) used as ORM much/at all.

**) In fact: all of core and many contributions have tests, but these are integration tests and a rare unit-test. Integration-tests (DrupalWebTest) install a clean Drupal-codebase+database for each single test. Your average core-testsuite taking over 8 hours to run is not an exception. TDD is simply not (yet) possible.

EDIT Reading into your examples: Drupal is particularly bad in the area of "form wizards", though it has seen improvement in Drupal 7. Another notable lack, in Drupal, is a proper, programmable workflowing system. There are several modules that enhance or replace the simple workflow-system in core, but they are not easy, nor efficient (development-effort-wise) to program against. It sounds like the main features you want, are amoungst the most underdeveloped areas in Drupal


This really depends on the needs of your application. Drupal, while flexible and extensible, is first a CMS and comes loaded with features which may or may not be desired for a web application. But if out-the-box or with additional modules it provide a large matches for the more classic web application features (ie. user management, content management, plugin system, theme layer, etc.), Drupal provides a great framework to avoid re-inventing the wheel (or dependencies on third party/less-mature framework plugins).

Drupal as a steeper learning curve compared to most framework. As a framework, Drupal is build and designed to for the CMS it is. Historically, Drupal puts almost everything in database. The situation is now better with the generalization of exportables and tools like the Features module. Also, unlike most framework Drupal does not use MVC and is mostly not object oriented.


Yes! You can use it as a framework. You'd want to be happy with some of the core APIs like the menu, node and probably the form API. The menu router and access control are quite good.

I've worked on a couple Drupal sites that didn't quite work because the core requirements had little to do with a CMS. Drupal is very flexible but it most suited to content management. You can of course use it as some satellite CMS for some other application. Drupal can also be used for service driven architecture.

If you want to scale up big, you might consider a framework that places more importance on testing and test driven practices. Drupal is a late adopter of these practices and is not mature in this area. It's something that I find frustrating especially on large sites where regression error becomes an issue. Consider something like Ruby on Rails if this is of interest to you.

Good luck!

Note to self: Why would I wish someone luck on a software project? ... interesting.


Drupal 8 change a lot.

- It is OOP
- Using Composer
- Have good cache mechanism in core
- RESTful in core

So now it is easy can be used as framework for any app. At end web all ways have content. E-commerce have content. And so on.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜