Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions .env

This file was deleted.

9 changes: 0 additions & 9 deletions .env.test

This file was deleted.

35 changes: 19 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Symfony 5.4 CI Pipeline
name: Symfony 3.4 CI Pipeline

# Trigger the workflow on push or pull requests for the develop, main, and master branches
on:
Expand All @@ -9,7 +9,7 @@ on:

jobs:
tests:
name: PHPUnit Tests (PHP 8.1)
name: PHPUnit Tests (PHP 7.4)
runs-on: ubuntu-latest

# Provision a containerized MySQL service for integration testing
Expand All @@ -32,13 +32,13 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v4

# 2. Setup PHP Environment with required extensions and tools for Symfony 5.4
# 2. Setup PHP Environment with required extensions and tools for Symfony 3.4
- name: Setup PHP Environment
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, xml, ctype, iconv, intl, pdo, pdo_mysql, mysqli
tools: composer:v2
php-version: '7.4'
extensions: mbstring, xml, ctype, iconv, pdo, pdo_mysql, mysqli
tools: composer:2.2
coverage: none # Disabled to optimize execution speed

# 3. Validate composer.json syntax and integrity
Expand All @@ -47,24 +47,27 @@ jobs:

# 4. Install Project Dependencies using Composer
- name: Install Dependencies
run: composer install --prefer-dist --no-progress
run: composer install --prefer-dist --no-progress --no-suggest

# 5. Inject Symfony 5.4 environment variables into GitHub Environment
# 5. Inject Symfony 3.4 parameters into GitHub Environment to override local settings
- name: Configure Test Environment Variables
run: |
echo "DATABASE_URL=mysql://root:@127.0.0.1:3306/todoco_db?serverVersion=5.7" >> $GITHUB_ENV
echo "APP_ENV=test" >> $GITHUB_ENV
echo "DATABASE_URL=mysql://root:@127.0.0.1:3306/todoco_db" >> $GITHUB_ENV
echo "SYMFONY__DATABASE_HOST=127.0.0.1" >> $GITHUB_ENV
echo "SYMFONY__DATABASE_PORT=3306" >> $GITHUB_ENV
echo "SYMFONY__DATABASE_NAME=todoco_db" >> $GITHUB_ENV
echo "SYMFONY__DATABASE_USER=root" >> $GITHUB_ENV
echo "SYMFONY__DATABASE_PASSWORD=" >> $GITHUB_ENV

# 6. Build the database schema using Doctrine console commands
- name: Create Test Database and Load Fixtures
- name: Initialize Database and Schema
run: |
php bin/console doctrine:database:create --env=test --if-not-exists
php bin/console doctrine:schema:update --env=test --force
php bin/console doctrine:fixtures:load --env=test --append -n
php bin/console doctrine:database:create --env=test --if-not-exists
php bin/console doctrine:schema:update --env=test --force

# 7. Hydrate the isolated database with fixtures (forced purge & load)
# 7. Hydrate the isolated database with fixtures
- name: Load Test Fixtures
run: php bin/console doctrine:fixtures:load --env=test --purge-with-truncate
run: php bin/console doctrine:fixtures:load --env=test -n

# 8. Execute the automated test suite
- name: Run Automated Test Suite
Expand Down
26 changes: 1 addition & 25 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,4 @@
/vendor/
/web/bundles/
/build/

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###

###> phpunit/phpunit ###
/phpunit.xml
/public/test-coverage/
.phpunit.result.cache
###< phpunit/phpunit ###
###> symfony/phpunit-bridge ###
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###

###> phpstan/phpstan ###
phpstan.neon
###< phpstan/phpstan ###
.env
/web/test-coverage/
134 changes: 47 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,97 +1,83 @@
# ToDo & Co Application

[![Symfony 5.4 CI Pipeline](https://github.com/Mike031289/ToDo-Co/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/Mike031289/ToDo-Co/actions/workflows/ci.yml)
[![Symfony 3.4 CI Pipeline](https://github.com/Mike031289/ToDo-Co/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/Mike031289/ToDo-Co/actions/workflows/ci.yml)

Base du projet **OpenClassrooms #8** : _Améliorez un projet existant_
Base du projet #8 : Améliorez un projet existant
https://openclassrooms.com/projects/ameliorer-un-projet-existant-1

---

# 📝 About the Project
## 📝 About The Project

This repository is dedicated to the modernization of the **ToDo & Co** web application.

The main objective of this project is to take over an existing legacy codebase (**Symfony 3.1 / PHP 5.5.9**), perform a thorough code quality audit, eliminate technical debt, and implement new technical requirements, including advanced user management, security policies, and a comprehensive automated testing suite using **PHPUnit**.
The main objective of this project is to take over an existing legacy codebase (**Symfony 3.1 / PHP 5.5.9**), perform a thorough code quality audit, fix critical technical debt, and implement new technical requirementsincluding advanced user management, security policies, and an exhaustive automated testing suite (PHPUnit).

## 🚀 Modernization Goals Achieved
### 🚀 Modernization Goals Achieved

- **Framework Upgrade:** Migrated the application from **Symfony 3.1** to **Symfony 5.4 LTS** and from **PHP 5.5.9** to **PHP 8.1**.
- **Security Overhaul:** Introduced multi-level roles, secured task ownership, and protected sensitive actions using Symfony **Voters**.
- **Quality Assurance:** Implemented an extensive automated test suite with **PHPUnit 9.6**, covering controllers, entities, forms, and business logic.
- **CI/CD Pipeline:** Configured **GitHub Actions** to automatically run tests, static analysis, and coding standards validation on every push and pull request.
- **Framework Upgrade:** Migrated the legacy application to **Symfony 3.4** and **PHP 7.4** to ensure stability and long-term dependency support.
- **Security Overhaul:** Implemented multi-level roles, isolated task ownership, and resolved security vulnerabilities using Symfony **Voters**.
- **Quality Assurance:** Built a comprehensive automated testing suite with **PHPUnit**, covering controllers, forms, and business logic.
- **CI/CD Pipeline:** Integrated **GitHub Actions** for continuous integration, including automated tests, static analysis, and code style validation on every push.

---

# 🛠️ Tech Stack
## 🛠️ Tech Stack

| Category | Technology |
| ----------------------------- | ----------------------------- |
| **Framework** | Symfony 5.4 |
| **Language** | PHP 8.1 |
| :---------------------------- | :---------------------------- |
| **Framework** | Symfony 3.4 |
| **Language** | PHP 7.4 |
| **Database** | MySQL / MariaDB |
| **Testing** | PHPUnit 9.6 |
| **Testing** | PHPUnit |
| **CI/CD** | GitHub Actions |
| **Static Analysis & Quality** | Codacy, PHPStan, PHP CS Fixer |
| **Migration Tool** | Rector (PHP 8.1 compatible) |
| **Debugging & Profiling** | Xdebug 3.x |

---

# 📖 Project Documentation
## 📖 Project Documentation

To simplify onboarding and long-term maintenance, the documentation is organized into dedicated guides.
To make onboarding and maintenance as smooth as possible, the documentation is split into dedicated guides:

## 📘 Installation & Contribution Guide (`CONTRIBUTING.md`)
### 📘 Installation & Contribution Guide (`CONTRIBUTING.md`)

This guide includes:
- Step-by-step local setup instructions.
- Database configuration and fixtures.
- Git workflow (branch naming and Conventional Commits).
- Commands to run the automated test suite.

- Local installation instructions
- Database configuration
- Fixture loading
- Git workflow (branch naming and Conventional Commits)
- Commands for running the automated test suite
### 🔐 Technical Security & Authentication (`doc/security.md`)

## 🔐 Technical Security & Authentication (`doc/TECHNICAL_SECURITY.md`)

This document describes:

- Authentication architecture
- Role hierarchy (`ROLE_USER` / `ROLE_ADMIN`)
- Route-level authorization
- Business authorization using `TaskVoter`
- Demo accounts for testing
- Authentication architecture overview.
- Role hierarchy (`ROLE_USER` / `ROLE_ADMIN`).
- Route-level authorization and `TaskVoter` rules.
- Demo accounts for testing.

---

# 🚦 Quick Start
## 🚦 Quick Start (Local Setup)

For complete installation instructions, see **CONTRIBUTING.md**.
For complete installation instructions, refer to **CONTRIBUTING.md**.

## 1. Install dependencies
### 1. Install dependencies

```bash
composer install
```

## 2. Configure the database

Update your database connection settings in your `.env` file (or your local environment configuration).
### 2. Configure the database

Example:

```dotenv
DATABASE_URL="mysql://user:password@127.0.0.1:3306/todo"
```
During installation, provide your local database credentials when `parameters.yml` is generated.

## 3. Create the database and load fixtures
### 3. Create the database and load fixtures

```bash
php bin/console doctrine:database:create
php bin/console doctrine:schema:create
php bin/console doctrine:fixtures:load --no-interaction
```

## 4. Start the local server
### 4. Start the local server

```bash
php bin/console server:start
Expand All @@ -105,61 +91,35 @@ http://127.0.0.1:8000

---

# 🧪 Running Tests & Code Coverage

## Run the complete test suite

```bash
vendor/bin/phpunit
```

## Run a specific test class

Task entity tests:

```bash
vendor/bin/phpunit tests/Entity/TaskTest.php
```
## 🧪 Running Tests

Task controller tests:
Run the complete automated test suite:

```bash
vendor/bin/phpunit tests/Controller/TaskControllerTest.php
php bin/phpunit
```

## Generate a code coverage report
Run a specific test file (example: Task controller security tests):

```bash
php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-text
php bin/phpunit tests/AppBundle/Controller/TaskControllerTest.php
```

---

# 📊 Quality Audit

Code quality is continuously monitored to ensure maintainability and compliance with Symfony best practices.

## ✅ Coding Standards

Coding style follows **PSR-12** and is automatically enforced using **PHP CS Fixer**.

## 🔍 Static Analysis
## 📊 Quality Audit

**PHPStan** is used to detect:
Code quality is continuously monitored to keep the project maintainable and compliant with Symfony best practices.

- Type inconsistencies
- Potential runtime errors
- Dead code
- Common programming mistakes
### ✅ Coding Standards

before deployment.
- PSR-12 compatibility enforced with **PHP CS Fixer**.

## 🔄 Continuous Integration
### 🔍 Static Analysis

Every push and pull request automatically triggers the GitHub Actions pipeline, which performs:
- **PHPStan** is used to detect type inconsistencies and potential runtime issues before deployment.

- PHPUnit test execution
- PHP CS Fixer validation
- PHPStan static analysis
### 🔄 Continuous Integration

Additionally, **Codacy** continuously reviews pull requests to monitor technical debt and maintain overall code quality.
- **GitHub Actions** automatically executes tests, code style checks, and static analysis.
- **Codacy** reviews every Pull Request to monitor technical debt and maintain code quality.
7 changes: 7 additions & 0 deletions app/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
7 changes: 7 additions & 0 deletions app/AppCache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;

class AppCache extends HttpCache
{
}
Loading
Loading