# PnP Development Guidelines

## Philosophy

**Just enough, nothing more.** This framework applies minimal PHP to enable modern conveniences while remaining maintainable for years or decades. Avoid rapidly changing components and dependencies. The code should be readable, simple, and only add what is strictly necessary.

## Core Principles

### Minimalism
- Use only what is strictly necessary to achieve the goal
- No frameworks, no build tools, no package managers for frontend code
- Avoid abstractions unless they provide clear, lasting value
- Sparse commenting—only mark main sections

### Technology Stack
- **Allowed:** HTML, PHP (8.4+), CSS
- **Not allowed:** JavaScript
- Use modern PHP features when they improve readability or performance
- Leverage modern CSS features for smart, efficient styling

### File-Based Routing
- Folder hierarchy dictates URL structure
- Drop a file (`.md`, `.php`, `.html`) in a folder and it renders immediately
- Assets placed in content directories are automatically accessible
- Directories with subfolders trigger list views

### Template System
- Custom templates override defaults (never modify defaults)
- Custom templates live in `/app/custom/`
- Default templates provide fallback behavior
- Docs get their own template variants for specialized presentation
- Templates use PHP includes—simple and straightforward

### Content Conventions

#### File Naming
- Cover images: `cover.jpg`, `cover.webp`, etc.

#### Date Formatting
- Folder names can include dates: `YYYY-MM-DD-title`
- Dates are automatically extracted and formatted (Norwegian format: "23. oktober 2025")
- Metadata can override automatic date detection

#### Metadata
- Use `metadata.ini` files for structured data
- Common fields: `title`, `date`, `summary`
- Metadata overrides automatic title/date extraction

### HTML & CSS Standards
- Classless CSS where possible
- HTML should be highly compliant with best practices
- Use semantic HTML5 elements
- Modern CSS features: custom properties, nesting, `oklch()` colors, grid, clamp, logical properties
- Responsive by default using fluid typography and flexible layouts

### Security
- Path validation prevents directory traversal
- Files must be within document root
- MIME types properly set for all served content
- No direct execution of arbitrary user input

### Code Style

#### PHP
- Modern syntax: arrow functions, null coalescing, match expressions
- Use type hints when practical
- Ternary operators for simple conditionals
- Keep functions focused and single-purpose

#### CSS
- Use CSS variables for theming
- Nesting for component-scoped styles
- Grid for layout, not tables or excessive flexbox
- `clamp()` for responsive sizing
- Avoid pixel values where relative units work better

#### Templates
- Escape output: `htmlspecialchars()` for user-generated content
- Short echo tags: `<?= $var ?>`
- Minimize logic in templates—prepare data beforehand

### Performance Considerations
- Page load time displayed in footer (transparency and pride in performance)
- CSS versioned with MD5 hash for cache busting
- Minimal HTTP requests through direct includes
- No JavaScript means no parsing delay

### Extensibility Patterns
- Third-party code goes in `/app/vendor/`
- Custom code goes in `/app/custom/`

### List Views
When a directory contains subdirectories:
- Default list template generates automatic listings
- Each item shows title, date, optional cover image, optional summary
- Override with custom list template for specialized presentation

## What This Framework Is Not

- Not a CMS with an admin panel
- Not a single-page application
- Not a JavaScript framework

## What This Framework Is

- A simple, intuitive way to publish content
- A foundation that will work for decades
