µm2 Web Framework

Originally started as an open source project by David Brännvall, µm2 (then called umvc) was refined and developed at HR North Sweden AB then the public mentorship has been taken over by Vovoid.

Why µm2?

Web development isn't what it used to be.

The MVC (model-2) design pattern alone doesn't cut it anymore. With modern JavaScript libraries like jQuery - JavaScript and CSS play a much bigger role than before.

Where do you draw the line? Do you only do GUI in plain generated HTML or do you do a mix of that, Ajax and CSS-driven GUI layout changes? The "view" has been severely fragmented in recent years.

Historically in frameworks, JavaScript has been a second class citizen, forced into the web root in the /js/ directory along with css and the images.

On the other hand, you don't want to keep multiple javascript files around, because it hampers performance. So you usually end up with the 3000 lines long Javascript file.

Why is this? The ideal high performance web application triggers only 4 requests to the web server - a html document, a .js file, a .css file and a "sprited" image file.

With µm2, all code and content (including javascript and css) is kept together in the module directory. The advantage for the programmer is that no file need exceed more than 100-300 lines of code, including js and css!

A good practice encouraged within µm2 is to encapsulate your css and javascript into separate namespaces, thus helping with module isolation. I.e. make a wrapper div with a special classs around your page and prefix every css attribute with it. Like so:

.main_page a { font-color: red; }

This can also be done with JavaScript.

Key Features

  • Module Centric - JavaScript, CSS, Images, Routing and Language translation data is stored together in the same folder with the controller and view forming a module. This makes them fully pluggable.
  • CSS and JS are combined automatically into one file, Images are copied into the web root automatically. We call this process "baking".
  • SEO/routing is done with pure PHP logic, no weird limited formats for specifying which module listens to what uri. This means you can trig on words or part of words in the URI string and fabricate the request. You have full control over internal routing which means you can change the URI layout of a site even after it has been released. This is also done on module level and subject to "baking".
  • Language support, building on the "per module" paradigm, we "bake" a cached language translation database. Backends supported are GNU gettext and MongoDB.
  • We strongly believe a PHP framework should not dictate what javascript library you are using (listen to how BAD that sounds). We leave that choice to you. (We use jQuery, thanks for asking, but prototype or any other works as good)
  • Per Project / Hostname overridables - you can override every file in a module - a controller, image or a javascript file - for a specific hostname or project. If you have a working codebase fulfilling a specific purpouse and you want to reuse this for multiple different customers, you can do that without even touching the original code. I.e. you have a basic web shop design and a specific customer wants the articles to sort backwards by default.
  • We make strong use of git and git submodules which means µm2 will not pollute your repository nor get in the way, you can update it and branch it and still do integration tests with new versions. µm2 is hosted on github making it as easy as ever to interact with us.

For more info