Studyportals' CMS

1.2.1 2022-01-24 16:06 UTC

This package is auto-updated.

Last update: 2022-01-27 08:39:47 UTC


README

The routing and page compositing framework behind Mastersportal.com et al.

Development

Requires PHP 7.2.

composer install

Test-coverage has been worked up substantially over the past years, but is not yet complete. A broad set of integration-tests is available; many unit-tests are still missing...

composer run phpunit

Apart from PHPUnit, there's full compliance with PHPStan, PSR-12 and a subset of PHPMD:

composer run phpstan
composer run phpstan:tests # slightly relaxed for tests/**

composer run phpcs

composer run phpmd
composer run phpmd:tests # slightly (more) relaxed for tests/**

Git-hooks

This project uses composer-git-hooks to enable the following Git-hooks:

  • pre-push – run all of the tests listed above.
  • checkout – upon switching branches, run an auto-update script and check if the repository is still in-sync with repo-template-php.
  • pre-commit – prevent committing directly in the master- and develop-branches; use pull-requests instead.

Using the CMS

With exception of the single code-snippet below, no documentation is available as of yet... 😇

The routing logic (e.g. translating path/to/a/page.html to the actual page to be displayed) is part of the CMS. Each individual implementation has to provide its own logic to handle the broader environment though. Things such as picking up signals from the HTTP-server, gracefully handling error conditions, issuing HTTP-redirects and managing client-side caching behaviour are not managed by the CMS.

The most basic implementation of the CMS looks something like this:

$site = $this->siteHandler->createSite();
$this->templateHandler->initTemplate($site);

// Set page according to virtual-path (e.g. via Apache RewriteRules)

$virtual_path = trim(
    $this->inputHandler->get(INPUT_GET, 'virtual_path') ?? ''
);

$site->getPageTree()->setPageByPath($virtual_path);

// Show page

echo (string) $site->getPage()->display();

Origins of the CMS

The CMS traces its origins back to around 2004. It has been powering Mastersportal.com (and its predecessor MastersPortal.eu) since mid-2007.

It started out as a fully fledged Content Management System (hence its name and that of many of its components), but over the years evolved into the routing and page compositing framework it currently is.

Notable features that got removed over the years:

  • A drag-and-drop WYSIWYG administrative interface allowing for on the fly modifictions of the site, with configuration stored in an SQL-database – replaced with a static page-tree defined using PHP classes.
  • Multi-language support (via the Accept-Language-header) including an interactive WYSIWYG editor enabling all static interface elements to be translated in situ – the sheer complexity of this approach never matched any of its returns; given the current structure of CMS, a simpler and equally effective approach can be constructed on top of this package.
  • A dynamic (i.e. runtime) asset "packer", reducing a multitude of JavaScript- and CSS-files to a limited set of asset "packs" (both site-wide and at the level of individual pages) – replaced by a Webpack-powered build-process (not part of this repository).

Notable contributors over the years: