mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
- Moved /lib → /src (PHP source code)
- Moved /includes → /public/includes (main site templates)
- Admin section remains self-contained in /public/admin with its own /inc
- Updated all require/include paths across codebase
- Updated config/bootstrap.php, justfile, tests, docs
- All tests passing ✅
Structure now follows PHP best practices:
/config - Configuration files
/database - SQLite database + schema
/docs - Documentation (intact)
/nginx - Server config (intact)
/public - Web-accessible files (entry point)
/admin - Self-contained admin interface
/assets - CSS, fonts, icons
/includes - Main site templates (header/footer)
/scripts - Deployment scripts (intact)
/src - PHP source classes (Database, AdminAuth, RateLimit)
/tests - Test suites
136 lines
3.4 KiB
Markdown
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` | `src/Database.php` |
|
|
| `shared/config.php` | `src/config.php` |
|
|
| `shared/cache/` | `src/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
|
|
```
|