Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9c4b64d9c | ||
|
|
27c15f747a | ||
|
|
d5871ed8e7 | ||
|
|
ad6e07c76d | ||
|
|
06310d9eb9 | ||
|
|
f679d0b20e |
@@ -0,0 +1 @@
|
||||
.claude/
|
||||
@@ -0,0 +1,59 @@
|
||||
# NovaconiumPHP
|
||||
|
||||
A lightweight PHP 8.1+ MVC-ish web framework/CMS toolkit (router + controllers + Twig views + Sass styling), authored by Nick Yeoman (4lt.ca) and distributed via Composer as `4lt/novaconium`. The canonical repo is hosted on a self-hosted Gitea instance (`git.4lt.ca`), not GitHub — do not assume `gh` CLI or GitHub Actions apply here.
|
||||
|
||||
## Directory map
|
||||
|
||||
- `src/` — core framework classes, namespace `Novaconium\` (PSR-4 → `src/`): `novaconium.php` (bootstrap), `Router.php`, `Database.php`, `Session.php`, `Redirect.php`, `Post.php`, `Logger.php`, `MessageHandler.php`, `functions.php`, `twig.php`, and `src/Services/` (`Auth.php`, `TagManager.php`).
|
||||
- `controllers/` — framework-level default controllers (dashboard, pages, messages, settings, auth/, sitemap, 404, init, create_admin, etc.).
|
||||
- `config/routes.php` — framework-level default route definitions, merged with app-level `App/routes.php` at runtime.
|
||||
- `views/` — Twig views mirroring controller names (`controllers/dashboard.php` ↔ `views/dashboard.html.twig`).
|
||||
- `twig/` — shared/partial Twig templates (layout pieces: `master.html.twig`, `nav.html.twig`, `head.html.twig`, `foot.html.twig`, `cp/` control-panel partials, `javascript/`).
|
||||
- `sass/` — framework's default Sass source (indented Sass, not SCSS), 7-1-ish structure: `abstracts/`, `base/`, `framework/`, `controlPanel/`, `coming-soon/`; has its own `Dockerfile` for compiling.
|
||||
- `skeleton/` — scaffold copied into a new consumer project on install: `.env`, `docker-compose.yml`, `novaconium/App/{config.php,routes.php,controllers,views,templates}`, `novaconium/public/{index.php,.htaccess,css,js}`, `novaconium/sass/project.sass`.
|
||||
- `docs/` — one short Markdown file per topic (see below).
|
||||
- `_assets/` — static assets (e.g. logo used in README).
|
||||
|
||||
## Build / run (Docker-only — no host tooling assumed)
|
||||
|
||||
**Agents (Claude Code, opencode, etc.) run inside containers and have no access to Docker.** Do not attempt to run any `docker`/`docker compose` command below — they will fail. These commands are documented for a human maintainer to run on their own host. If you need to verify a change, do so by reading/reasoning about the code, not by invoking Docker.
|
||||
|
||||
**Composer** (per `docs/Composer.md`):
|
||||
```
|
||||
docker run --rm --interactive --tty --volume $PWD:/app composer:latest require 4lt/novaconium
|
||||
docker run --rm --interactive --tty --volume $PWD:/app composer:latest update
|
||||
```
|
||||
|
||||
**Sass build** (per `docs/Sass.md`), using `sass/Dockerfile`:
|
||||
```
|
||||
cd sass && docker build -t sass-container .
|
||||
docker run --rm -v $(pwd):/usr/src/app -w /usr/src/app sass-container sass novaconium/sass/project.sass novaconium/public/css/novaconium.css
|
||||
```
|
||||
Compressed variant: add `--style=compressed`, e.g.
|
||||
```
|
||||
docker run --rm -v $(pwd):/usr/src/app -w /usr/src/app sass-container --style=compressed sass/novaconium.sass skeleton/novaconium/public/css/novaconium.css
|
||||
```
|
||||
|
||||
**Dev stack**: `docker compose up -d` from `skeleton/docker-compose.yml` — services: `4lights/corxn:8.5.3` (Apache+PHP), `redis`, `mariadb`, `phpmyadmin`.
|
||||
|
||||
**Testing a cloned copy without reinstalling via Composer**: see `docs/Dev-Fake_autoload.md` for the fake-autoload dev trick.
|
||||
|
||||
## No test suite / lint / CI
|
||||
|
||||
There is no `phpunit.xml`, no lint config (no PHPCS, `.editorconfig`, ESLint), and no CI pipeline in this repo. Don't hunt for `npm test`/`phpunit`/lint commands — none exist.
|
||||
|
||||
## Conventions
|
||||
|
||||
- PSR-4 autoloading: `Novaconium\` → `src/`.
|
||||
- Controllers and views are name-paired by default (e.g. `controllers/dashboard.php` ↔ `views/dashboard.html.twig`), but this is only a convention — a controller can render any view, they are not required to match.
|
||||
- Sass partials are prefixed `_` (e.g. `_forms.sass`), aggregated per-folder via `index.sass`.
|
||||
- App-level config (`App/config.php`) is a multi-dimensional PHP array: database credentials, `base_url`, `secure_key`, `logfile`, `loglevel`.
|
||||
- Versioning strategy is semantic-versioning (declared in `composer.json` `extra.versioning`).
|
||||
|
||||
## Git workflow
|
||||
|
||||
Single `master` branch (no `main`), tracking a self-hosted Gitea remote. Solo-maintainer, trunk-based, direct commits to `master` with short informal messages — no conventional-commits enforcement, no PR-based tooling assumptions.
|
||||
|
||||
## Further reading
|
||||
|
||||
See `docs/*.md` for per-topic detail: `404.md`, `Composer.md`, `ConfigurationFile.md`, `Dev-Fake_autoload.md`, `Logs.md`, `Messages.md`, `Post.md`, `Redirect.md`, `Sass.md`, `Session.md`, `StyleSheets-sass.md`, `Twig-Views.md`, `docker.md`.
|
||||
@@ -6,13 +6,20 @@ NovaconiumPHP is a high-performance PHP framework designed with inspiration from
|
||||
|
||||
Pronounced: Noh-vah-koh-nee-um
|
||||
|
||||
Packagist: https://packagist.org/packages/4lt/novaconium
|
||||
Master Repo: https://git.4lt.ca/4lt/novaconium
|
||||
* Packagist: https://packagist.org/packages/4lt/novaconium
|
||||
* Master Repo: https://git.4lt.ca/4lt/novaconium
|
||||
|
||||
## Getting Started
|
||||
|
||||
Novaconium is heavly influenced by docker, but you can use composer outside of docker.
|
||||
You can [learn more about how novaconium works with composer](https://git.4lt.ca/4lt/novaconium/src/branch/master/docs/Install-Composer-On-Debian.md).
|
||||
Novaconium is designed to be developed primarily using Docker. Instead of relying on tools installed directly on your system, common development tasks are executed inside containers:
|
||||
|
||||
* Composer runs inside a Docker container rather than on your host machine
|
||||
* Apache / PHP are served from containers instead of your local environment
|
||||
* Sass compilation is also handled within a container
|
||||
|
||||
As long as you have Docker installed, you can use the full development environment without installing additional dependencies on your system.
|
||||
|
||||
You can [learn more about how novaconium works with composer](https://git.4lt.ca/4lt/novaconium/src/branch/master/docs/Composer.md).
|
||||
|
||||
```bash
|
||||
PROJECTNAME=novaproject;
|
||||
@@ -24,9 +31,9 @@ docker run --rm --interactive --tty --volume ./novaconium/:/app composer:latest
|
||||
cp -R novaconium/vendor/4lt/novaconium/skeleton/. .;
|
||||
|
||||
# Edit .env
|
||||
# pwgen -cnsB1v 12 root password
|
||||
# pwgen -cnsB1v 12 mysql user password (need in both config and env)
|
||||
# pwgen -cnsB1v 64 framework key (need in config)
|
||||
# pwgen -cnsB1v 12 # root password
|
||||
# pwgen -cnsB1v 12 # mysql user password (need in both config and env)
|
||||
# pwgen -cnsB1v 64 # framework key (need in config)
|
||||
# Edit novaconium/App/config.php
|
||||
|
||||
docker compose up -d
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ Update novaconium with composer in docker: ```docker run --rm --interactive --tt
|
||||
|
||||
## Install Composer natively on Debian
|
||||
|
||||
Assuming you have nala installed:
|
||||
Assuming you have nala installed (otherwise use apt-get):
|
||||
|
||||
```bash
|
||||
sudo nala install curl php-cli php-mbstring git unzip
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
# Sample Docker Compose
|
||||
services:
|
||||
corxn:
|
||||
image: 4lights/corxn:6.0.0
|
||||
image: 4lights/corxn:8.5.3
|
||||
ports:
|
||||
- "8000:80"
|
||||
volumes:
|
||||
- "/etc/timezone:/etc/timezone:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- ./novaconium:/data
|
||||
- ./data/logs:/var/log/apache2 # Optional Logs
|
||||
- "./logs:/data/logs"
|
||||
@@ -29,8 +27,6 @@ services:
|
||||
MYSQL_USER: novaconium
|
||||
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
|
||||
volumes:
|
||||
- "/etc/timezone:/etc/timezone:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- ./data/db:/var/lib/mysql
|
||||
networks:
|
||||
- internal
|
||||
@@ -49,9 +45,6 @@ services:
|
||||
- PMA_USER=root
|
||||
- PMA_PASSWORD=${MYSQL_ROOT_PASSWORD}
|
||||
- UPLOAD_LIMIT=200M
|
||||
volumes:
|
||||
- "/etc/timezone:/etc/timezone:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// ini_set('display_errors', 1);
|
||||
|
||||
// Define the base path where the website is running from
|
||||
define('BASEPATH', dirname(__DIR__, 1));
|
||||
define('BASEPATH', dirname(__DIR__));
|
||||
|
||||
// Load Composer's autoload file to handle class autoloading
|
||||
require BASEPATH . '/vendor/autoload.php';
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@ class Router {
|
||||
}
|
||||
|
||||
private function getRequestType() {
|
||||
// is the requewst a get or post?
|
||||
// is the request a get or post?
|
||||
if (empty($_POST)) {
|
||||
return 'get';
|
||||
} else {
|
||||
@@ -75,7 +75,7 @@ class Router {
|
||||
|
||||
foreach ($this->routes as $key => $value) {
|
||||
// Check if key contains a curly bracket, if not continue. We already checked above.
|
||||
if (!strpos($key, '{')) continue;
|
||||
if (strpos($key, '{') === false) continue;
|
||||
|
||||
// Remove everything after the curly bracket, from key
|
||||
$keyPath = substr($key, 0, strpos($key, '{'));
|
||||
|
||||
+11
-7
@@ -1,5 +1,16 @@
|
||||
<?php
|
||||
|
||||
use Novaconium\Logger;
|
||||
use Novaconium\Session;
|
||||
use Novaconium\MessageHandler;
|
||||
use Novaconium\Database;
|
||||
use Novaconium\Post;
|
||||
use Novaconium\Redirect;
|
||||
use Novaconium\Router;
|
||||
|
||||
$db = null;
|
||||
$post = null;
|
||||
|
||||
// --- Load Config ---
|
||||
if (file_exists(\BASEPATH . '/App/config.php')) {
|
||||
require_once \BASEPATH . '/App/config.php';
|
||||
@@ -11,7 +22,6 @@ require_once \FRAMEWORKPATH . '/src/functions.php';
|
||||
require_once \FRAMEWORKPATH . '/src/twig.php';
|
||||
|
||||
// --- Logging ---
|
||||
use Novaconium\Logger;
|
||||
$log = new Logger(\BASEPATH . $config['logfile'], $config['loglevel']);
|
||||
|
||||
// --- Twig Data Array ---
|
||||
@@ -21,35 +31,29 @@ $data['matomo_url'] = $config['matomo_url'] ?? '';
|
||||
$data['matomo_id'] = $config['matomo_id'] ?? '0';
|
||||
|
||||
// --- Session ---
|
||||
use Novaconium\Session;
|
||||
$session = new Session();
|
||||
$data['token'] = $session->get('token');
|
||||
$data['username'] = $session->get('username');
|
||||
|
||||
// --- Messages ---
|
||||
use Novaconium\MessageHandler;
|
||||
$messages = new MessageHandler($session->flash('messages'));
|
||||
foreach (['error', 'notice'] as $key) {
|
||||
$data[$key] = $messages->showMessages($key);
|
||||
}
|
||||
|
||||
// --- Database ---
|
||||
use Novaconium\Database;
|
||||
if (!empty($config['database']['host'])) {
|
||||
$db = new Database($config['database']);
|
||||
}
|
||||
|
||||
// --- POST Wrapper ---
|
||||
use Novaconium\Post;
|
||||
if (!empty($_POST)) {
|
||||
$post = new Post($_POST);
|
||||
}
|
||||
|
||||
// --- Redirect Handler ---
|
||||
use Novaconium\Redirect;
|
||||
$redirect = new Redirect();
|
||||
|
||||
// --- Router ---
|
||||
use Novaconium\Router;
|
||||
$router = new Router();
|
||||
require_once $router->controllerPath;
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@
|
||||
>
|
||||
|
||||
{# STYLESHEET #}
|
||||
<link rel="stylesheet" href="/css/main.css">
|
||||
<link rel="stylesheet" href="/css/novaconium.css">
|
||||
|
||||
{# highlight.js #}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user