Skip to main content
Version: Fegg 5.x

Fegg Coding Guide

info

This is the guide for Fegg 5. If your project still uses Fegg 4 (fegg/ and code/ directories), switch to Fegg 4.x in the version dropdown in the navbar.

About Fegg​

Fegg is a small PHP framework, originally created by Genies, Inc. and extended by LionHeart with a CMS foundation (login, media and image management, post types).

LionHeart projects start from the skeleton repository lionheart-group/lh-fegg-skelton. It contains Fegg, the CMS, sample pages (top page, news, contact form) and the frontend build setup.

Features​

  • PHP 7.4 to 8.5 are supported.
  • Core and site are separated.
    • htdocs/_fegg/core/ is the core: the framework and the CMS foundation shared by every project. Do not edit it. fegg-cli core:update replaces it as a whole, the same way you update WordPress itself.
    • htdocs/_fegg/site/ is the site: your project's controllers, templates and settings. Updates never touch it.
    • To change something the core provides (a CMS template, a CMS screen, a setting), override it from site/.
  • Several sites in one project. Each site (the site at /, a recruiting site at /recruit/ ...) has its own folder of templates, SCSS, JS and images in site/template/<site>/ (see Sites). A site without the CMS turns it off with $settings['cms'] = false.
  • Namespaces and autoloading. Controllers are Site\Controller\... classes and framework classes are Fegg\... (Fegg\Model, Fegg\Tool\Validation, Fegg\Tool\Mail, ...). Create classes with new.
  • Errors fail loudly. Database errors throw Fegg\Database\QueryException and missing templates throw Fegg\Template\TemplateException. Uncaught, both become a logged HTTP 500 (the error page site/template/error/500.html can be your own). Fegg\Log writes the application log.
  • Per-server settings and secrets come from site/config/env.php (not committed) or environment variables, read with feggEnv(). FEGG_ENV (production unless set) decides whether developers see error details.
  • Secure by default. Security headers on every response, sessions only when needed (HttpOnly, SameSite=Lax, strict mode), CSRF tokens in the CMS, login throttling, upload content checks.
  • SQLite or MySQL. fegg-cli migration works on both.
  • A modern CMS. The CMS's scripts are plain JavaScript. Rich text fields use FeggEditor (Tiptap), with columns, galleries, buttons, maps and links to files, and the saved HTML is cleaned on the server. The icons are Tabler Icons. See CMS screens and the editor.
  • Command line tools. fegg-cli checks templates (template:lint), lists the database schema (db:schema), adds sites (site:create), manages CMS users (user:create), updates the core (core:update) and checks that _fegg/ cannot be read from the web (doctor).

Fegg 3 / 4 projects are rebuilt from the skeleton: see Moving a Fegg 3 / 4 project.

Where to start​