Tools For Better Developers

Osm Framework

Learn how Osm Framework works, how to use and extend it. We publish the information here first, and some of it is eventually added to the official Osm Framework documentation. For even more details, check its source on GitHub.

Framework: Hydration

2021 November Osm Framework

8 months ago ∙ 2 minutes read

Recently, I developed a couple of helper functions for transmitting PHP objects over the wire, and saving them in database records:

  • dehydrate() - recursively converts an instance of a PHP class to a plain untyped object. Then, store the plain object in the database, or convert it to JSON and send it to a browser.
  • hydrate() - recursively converts a plain untyped object back to a PHP class instance. Use if after decoding a JSON received from the browser, or after loading a database record.

This article describes how to use these functions.

Framework: Modal Elements

2021 November Osm Framework

9 months ago ∙ 2 minutes read

When active, modal elements - dialogs, pickers, or AJAX spinners - need to prevent user interaction with the rest of the page.

A common approach is putting an overlay <div> under the modal element covering the rest of the page, as a click shield. However, user can still navigate the page with the keyboard.

Today, I implemented a better solution by capturing mouse and keyboard events outside the modal element, and keeping focus inside.

Framework: Application

2021 September Osm Framework

10 months ago ∙ 4 minutes read

In Osm Framework, an application is a set of modules that you run as a whole. There are several applications defined in the project, each having its own PHP class. Mostly, deal with the main one, Osm\App\App. Beside the class name, every application also has a name, the main one is named Osm_App.

Access the current application object, and the main parts of Osm Framework, via the global $osm_app object and its properties. Add your own long-living objects there. Run an application using its HTTP or console entry point, or using Apps::run().

Note. This post is moved to Osm Framework documentation.

Framework: Modules

2021 September Osm Framework

10 months ago ∙ 4 minutes read

Modular software development is a well-known practice of dividing your application into several modules, each doing one thing, and doing it well. It increases readability and simplifies maintenance, as application concerns are fully separated from one another, easier to reason about, and to debug.

Modular development also encourages reuse. It's like a puzzle. Using one set of modules, you'll get an e-commerce application, using another set of modules - you'll get a blog application.

Note. This post is moved to Osm Framework documentation.