How linarphy/phosphore works
1. What this repo is
- PHosPhore is a PHP 8 framework for building multi-page websites.
- Its architecture is file- and folder-driven: pages, classes, configs, templates, translations, and modules are all organized in parallel directory trees rather than being generated dynamically.
2. Bootstrap and runtime entry
- The runtime starts at src/index.php.
- Shared startup logic lives in src/func/core/init.php and utility helpers in src/func/core/utils.php.
- The framework appears to centralize initialization, then load configuration, routing, and page logic from the filesystem.
3. Core framework layer
- src/class/core contains the foundational abstractions:
- Base, Managed, Manager
- LinkManager
- Token
- DBFactory
- This is the framework’s “engine room”: object lifecycle, entity management, relation/link handling, token handling, and database connection creation.
4. Routing and request dispatch
- src/class/route models URL routing with Router, Route, Folder, and Parameter.
- Route-specific configuration exists in src/config/class/route/config.php.
- The route layer likely maps request paths into the corresponding page folder under src/page/... and handles path parameters.
5. Page system
- Actual pages are stored under src/page as standalone page definitions, each with a page.php.
- The repo currently includes at least:
- src/page/main/home/page.php
- src/page/error/page.php
- This suggests page controllers are filesystem-backed and are likely the endpoint of the routing flow.
6. Presentation and page elements
- UI rendering is split between:
- templates/assets in src/asset/template
- page element classes in src/class/content/pageelement
- There are default HTML presets for reusable elements like PageElement and NotificationElement.
- src/asset/css/core/main.css is the shared stylesheet, so styling is centralized but not tied to a web framework frontend stack.
7. User, permissions, and notifications
- src/class/user contains domain objects for:
- User, Visitor
- Role, Permission
- Password, Token
- Page, Notification
- Config folders under src/config/class/user/... indicate these are configurable subsystems, not just data models.
- This boundary suggests authentication, authorization, and user-visible notifications are first-class framework concerns.
8. Database layer
- Persistence is abstracted through src/class/database, including request and parameter.
- Database setup is configured through src/config/class/core/DBFactory/config.php.
- The README says the framework supports MySQL/MariaDB/PostgreSQL, so the architecture is database-agnostic at the abstraction layer, with DB-specific behavior hidden behind the factory/request APIs.
9. Modules and extension points
- The repo includes src/mod/installed, plus documentation for modules under doc/module.
- A hook system is present in src/hook/list.xml.
- This means the framework is designed for plugin/module extension, with modules installed into a dedicated folder and integrated through hooks rather than direct code modification.
10. Configuration as a parallel tree
- Configuration lives in src/config, mirrored to the class tree:
- class/content/pageelement
- class/core/DBFactory
- class/core/Logger
- class/route
- class/user/*
- This structure indicates classes are meant to be portable and configurable by matching config files, rather than hardcoding behavior in constructors.
11. Localization and message catalogs
- Text resources are split into src/lang and src/locale.
- Both mirror the class/page structure and contain en.* files for individual components and pages.
- This means user-facing strings are externalized per subsystem, which is important for any architecture diagram showing presentation, domain, and translation boundaries.
12. Documentation and conceptual model
- The doc/ tree is not just marketing text; it documents framework concepts such as:
- folders
- globals
- permissions
- routes
- variables
- processes
- page elements
- That strongly suggests the framework’s runtime model is built around these named concepts, and the docs likely reflect the intended architecture closely.
13. Key architectural boundary to diagram
- The clearest separation is:
- bootstrap/runtime (index.php, func)
- framework classes (class)
- configuration (config)
- presentation assets/templates (asset)
- pages (page)
- translations (lang, locale)
- modules/hooks (mod, hook)
- This separation is likely the most accurate way to draw the system, since the repo is explicitly organized around those directories.
14. Likely request flow
- A request enters through index.php, initialization loads config and core services, routing resolves the target page, page logic assembles content elements, templates render the response, and domain services may access the DB, user subsystem, or installed modules as needed.
Main entry points: init.php init · index.php index.php · config.php DBFactory · page.php home page
Components 24
Bootstrap
Entry point and shared startup logic.
- index.php · Main runtime entry.
src/index.php - init · Shared initialization flow.
src/func/core/init.php - utils · Common runtime helpers.
src/func/core/utils.php - core config · Global framework configuration.
src/config/core/config.php
Core
Foundational framework classes and services.
- Base · Foundational base object.
- Manager · Lifecycle and collection manager.
- LinkManager · Relationship and link handling.
- DBFactory · Database connection factory.
src/config/class/core/DBFactory/config.php
Routing & Pages
Request dispatch and filesystem-backed pages.
- Router · Top-level request router.
- Route · Concrete route mapping.
- Folder · Filesystem route grouping.
- Parameter · Path parameter model.
- home page · Main landing page.
src/page/main/home/page.php - error page · Fallback error page.
src/page/error/page.php
Presentation
Templates, assets, and page elements.
- PageElement · Reusable page element abstraction.
src/asset/template/preset/default/html/PageElement.html - Notification · Notification element preset.
src/asset/template/preset/default/html/NotificationElement.html - main.css · Shared base styling.
src/asset/css/core/main.css
Data & User
Persistence and user-related domain objects.
- User · User identity and account model.
- Permission · Authorization rules.
- Notification · User-facing notification model.
Modules & Hooks
Extension points and installed modules.
- hook list · Framework hook registry.
src/hook/list.xml - installed mods · Installed module area.
src/mod/installed
Localization
Language and locale resources.
- core lang · Global language resources.
src/lang/core/en.lang.php - core locale · Global locale resources.
src/locale/core/en.locale.php
Connections 20
- index.php → init: boots · Starts shared initialization.
- index.php → core config: loads · Reads global configuration.
- init → utils: uses · Shares common helpers.
- init → Router: creates · Initializes request dispatch.
- init → DBFactory: binds · Sets up database access.
- init → hook list: registers · Loads extension hooks.
- Router → Route: resolves · Maps a request to a route.
- Route → Folder: groups · Organizes route folders.
- Route → Parameter: parses · Handles route parameters.
- Router → home page: dispatches · Resolves the home page.
- Router → error page: falls back · Uses error page on failure.
- home page → PageElement: renders · Builds the page from elements.
- error page → Notification: renders · Uses notification-oriented UI.
- PageElement → main.css: styled by · Uses shared stylesheet.
- DBFactory → User: serves · Supports persistence for domain objects.
- User → Permission: governs · Authorization boundary.
- User → Notification: receives · User-visible notifications.
- installed mods → hook list: integrates · Modules connect through hooks.
- core lang → Base: describes · Localization for core classes.
- core locale → Router: localizes · Locale resources mirror runtime classes.