PHPackages                             julienlinard/php-skeleton - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. julienlinard/php-skeleton

ActiveProject[Framework](/categories/framework)

julienlinard/php-skeleton
=========================

Skeleton minimal utilisant mes libraries PHP (router, core, auth, doctrine).

1.5.13(4mo ago)883MITPHPPHP ^8.1

Since Dec 21Pushed 3mo agoCompare

[ Source](https://github.com/julien-lin/php-skeleton)[ Packagist](https://packagist.org/packages/julienlinard/php-skeleton)[ Docs](https://github.com/julien-lin/php-skeleton)[ RSS](/packages/julienlinard-php-skeleton/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (25)Used By (0)

PHP Skeleton v1.5.8
===================

[](#php-skeleton-v158)

[🇫🇷 Read in French](README.fr.md) | [🇬🇧 Read in English](README.md)

💝 Support the project
---------------------

[](#-support-the-project)

If this skeleton is useful to you, consider [becoming a sponsor](https://github.com/sponsors/julien-lin) to support the development and maintenance of this open source project.

---

A minimal PHP project skeleton using my PHP libraries (router, core, auth, doctrine). Perfect starting point for building modern PHP applications with clean architecture and production-ready structure.

✨ Features
----------

[](#-features)

- **🚀 Production-Ready** - Fully configured and optimized out of the box
- **🏗️ Clean Architecture** - Well-organized structure with service layer
- **🔒 Security First** - Mass assignment protection, open redirect prevention, secure sessions, CSRF protection
- **📦 Auto-Generated Services** - EnvValidator, BootstrapService, EventListenerService
- **🌐 Multilingual Support** - Validation messages in French, English, Spanish
- **🐳 Docker Ready** - Complete Docker setup with Apache and MariaDB
- **⚡ Zero Configuration** - Works immediately after installation
- **⚡ Performance Optimized** - View caching, container scoped cache, rate limiting

🚀 Installation
--------------

[](#-installation)

Create a new project using Composer:

```
composer create-project julienlinard/php-skeleton my-app
```

This will create a new directory `my-app` with the skeleton structure and launch an interactive installer.

📦 What's Included
-----------------

[](#-whats-included)

- **Core PHP Framework** - MVC structure with dependency injection container
- **Router** - Modern routing with PHP 8 attributes
- **Form Validation** - Advanced validation powered by php-validator with multilingual support
- **Logging** - Integrated SimpleLogger with structured logging
- **Error Handling** - Comprehensive error handling with debug/production modes
- **Session Management** - Secure session handling with flash messages
- **Optional: Doctrine PHP** - ORM for database management
- **Optional: Auth PHP** - Authentication and authorization system

🎯 Interactive Installation
--------------------------

[](#-interactive-installation)

After running `composer create-project`, an interactive installer will guide you through the setup:

### Step 1: Choose Environment

[](#step-1-choose-environment)

- **Use Docker?** - Choose `y` for Docker setup or `N` for local development

### Step 2: Docker Configuration (if Docker selected)

[](#step-2-docker-configuration-if-docker-selected)

The installer will ask you to configure:

- Apache container name and port
- MariaDB container name and port
- Database credentials (root password, database name, user, password)
- PHP error reporting settings

Two `.env` files will be automatically generated:

- Root `.env` - For Docker Compose configuration
- `www/.env` - For application configuration

### Step 3: Optional Packages

[](#step-3-optional-packages)

- **Install Doctrine?** - Adds database ORM capabilities
- **Install Auth?** - Adds authentication system

Simply answer `y` for yes or `N` for no (default).

**The autoloader is automatically regenerated** after installation, so your application is ready to run immediately!

⚡ Quick Start
-------------

[](#-quick-start)

### Option A: Docker Setup

[](#option-a-docker-setup)

If you chose Docker during installation:

```
cd my-app

# Load aliases (optional but recommended)
source aliases.sh

# Start Docker containers
docker compose up -d

# Install dependencies in container
cd www
ccomposer install

# Visit your application
# http://localhost (or the port you configured)
```

**Useful Docker aliases** (after sourcing `aliases.sh`):

- `ccomposer` - Run Composer commands in container
- `capache` - Enter Apache container shell
- `cmariadb` - Enter MariaDB container shell
- `db-export` - Export database backup
- `db-import` - Import database backup

### Option B: Local Setup

[](#option-b-local-setup)

If you chose local development:

```
cd my-app

# Install dependencies
composer install

# Start the development server
php -S localhost:8000 -t public

# Visit your application
# http://localhost:8000
```

📁 Project Structure
-------------------

[](#-project-structure)

### Docker Setup Structure

[](#docker-setup-structure)

```
my-app/
├── apache/              # Docker Apache configuration
│   ├── Dockerfile
│   └── custom-php.ini
├── db/                  # Database scripts
│   ├── backup.sh
│   └── restore.sh
├── www/                 # Application root (Docker)
│   ├── config/          # Configuration files
│   │   └── database.php # Secure database config
│   ├── migrations/      # Database migrations
│   ├── public/          # Public entry point
│   │   ├── index.php    # Bootstrap file
│   │   └── .htaccess    # Apache rewrite rules
│   ├── src/             # Application source code
│   │   ├── Controller/   # Controllers
│   │   ├── Entity/      # Doctrine entities
│   │   ├── Middleware/  # Custom middlewares
│   │   ├── Repository/  # Data repositories
│   │   └── Service/     # Business logic services
│   │       ├── BootstrapService.php      # Bootstrap configuration
│   │       ├── EnvValidator.php          # Environment validation
│   │       └── EventListenerService.php  # Event listeners
│   ├── storage/         # Storage directory
│   │   └── logs/        # Application logs
│   ├── views/           # View templates
│   │   ├── _templates/  # Layout templates
│   │   └── home/        # Page views
│   ├── .env             # Application environment variables
│   ├── .env.example     # Environment template
│   ├── .gitignore       # Git ignore rules
│   └── composer.json    # Project dependencies
├── .env                 # Docker Compose environment variables
├── .env.example         # Docker environment template
├── aliases.sh           # Docker aliases
├── docker-compose.yml   # Docker Compose config
└── composer.json        # Root composer.json

```

### Local Setup Structure

[](#local-setup-structure)

```
my-app/
├── config/              # Configuration files
├── migrations/          # Database migrations
├── public/              # Public entry point
├── src/                # Application source code
│   └── Service/        # Auto-generated services
├── storage/            # Storage directory
│   └── logs/          # Application logs
├── views/              # View templates
├── .env               # Environment variables
├── .env.example       # Environment template
└── composer.json      # Project dependencies

```

🛠️ Auto-Generated Services
--------------------------

[](#️-auto-generated-services)

The skeleton automatically generates three essential services:

### 1. EnvValidator

[](#1-envvalidator)

Validates environment variables on application startup:

- `APP_SECRET` validation (minimum 32 characters)
- `APP_LOCALE` validation (supported: fr, en, es)

### 2. BootstrapService

[](#2-bootstrapservice)

Centralizes bootstrap configuration:

- Debug mode configuration
- Error handler setup with logging
- Session security configuration

### 3. EventListenerService

[](#3-eventlistenerservice)

Registers application event listeners:

- Request logging
- Response logging
- Exception logging

📚 Available Packages
--------------------

[](#-available-packages)

This skeleton uses the following packages:

- **[julienlinard/php-router](https://packagist.org/packages/julienlinard/php-router)** - Modern router with PHP 8 attributes
- **[julienlinard/core-php](https://packagist.org/packages/julienlinard/core-php)** - MVC framework with DI container
- **[julienlinard/php-validator](https://packagist.org/packages/julienlinard/php-validator)** - Advanced validation with multilingual support
- **[julienlinard/doctrine-php](https://packagist.org/packages/julienlinard/doctrine-php)** - ORM (optional)
- **[julienlinard/auth-php](https://packagist.org/packages/julienlinard/auth-php)** - Authentication (optional)

🛠️ Development
--------------

[](#️-development)

### Adding Controllers

[](#adding-controllers)

Create controllers in the `src/Controller/` directory. Controllers should extend the base `Controller` class:

```
