Files
xamxam/docs/RESTRUCTURE_PLAN.md
Théophile Gervreau-Mercier d2b3c6ca67 Major refactor
- update the structure to have monolithic setup
- updated deployments
- added live-reloading for devops
2026-02-05 20:16:19 +01:00

136 lines
3.4 KiB
Markdown

# Repository Restructure Plan
## Current Structure
```
posterg-website/
├── apps/
│ ├── public/ # Public website
│ └── admin/ # Admin panel
├── shared/ # Shared PHP libraries
├── database/ # Database files
├── nginx/ # Server config
└── docs/ # Documentation
```
## Proposed Structure (Idiomatic PHP)
```
posterg-website/
├── index.php # Public website root
├── memoire.php
├── search.php
├── apropos.php
├── contact.php
├── licences.php
├── assets/ # Static files (CSS, JS, images)
│ ├── posterg.css
│ ├── normalize.css
│ └── fonts/
├── inc/ # Page templates/partials
│ ├── header.php
│ └── footer.php
├── lib/ # Shared libraries (renamed from shared/)
│ ├── Database.php
│ ├── RateLimit.php
│ ├── config.php
│ └── cache/
├── admin/ # Admin panel (from apps/admin/)
│ ├── index.php
│ ├── list.php
│ ├── edit.php
│ └── ...
├── database/ # Database files & schema
│ ├── schema.sql
│ ├── test.db
│ └── ...
├── vendor/ # Third-party dependencies (gitignored)
│ └── php-live-reload/ # Local dev only
├── nginx/ # Server configuration
├── docs/ # Documentation
├── tests/ # Tests (future)
└── .gitignore # Updated
```
## Benefits
**Standard PHP structure** - Follows common conventions
**Flatter hierarchy** - Easier to navigate
**Clear separation** - lib/ for code, inc/ for templates, assets/ for static files
**Simpler paths** - Less `../../` in require statements
**Vendor folder** - Standard for third-party code
## Migration Steps
### 1. Move public to root
```bash
mv apps/public/* .
```
### 2. Move admin
```bash
mv apps/admin admin/
rm -rf apps/
```
### 3. Rename shared to lib
```bash
mv shared lib/
```
### 4. Update all require paths
- `require_once __DIR__ . '/shared/Database.php'``require_once __DIR__ . '/lib/Database.php'`
- `require_once __DIR__ . '/../shared/Database.php'``require_once __DIR__ . '/../lib/Database.php'`
### 5. Setup vendor for local dev
```bash
mkdir -p vendor/
echo "vendor/" >> .gitignore
```
## Path Changes Summary
| Old Path | New Path |
|----------|----------|
| `apps/public/index.php` | `index.php` |
| `apps/public/inc/header.php` | `inc/header.php` |
| `apps/public/assets/posterg.css` | `assets/posterg.css` |
| `apps/admin/index.php` | `admin/index.php` |
| `shared/Database.php` | `lib/Database.php` |
| `shared/config.php` | `lib/config.php` |
| `shared/cache/` | `lib/cache/` |
## Deployment Changes
### Before
```
rsync apps/public/ posterg:/var/www/html/
rsync apps/admin/ posterg:/var/www/html/formulaire/
rsync shared/ posterg:/var/www/html/shared/
```
### After
```
rsync --exclude 'vendor' --exclude 'tests' . posterg:/var/www/html/
```
Much simpler!
## PHP Live Reload Setup
### For Local Development Only
1. Clone to `vendor/php-live-reload/` (gitignored)
2. Include in local dev server
3. Auto-refresh browser on file changes
4. Never deployed to production
### Usage
```bash
# Setup (one time)
just setup-dev
# Start dev server with live reload
just serve-public # or serve-admin
```