From 2c2b893558afbfda209fd7ba6f85060d5f05bce3 Mon Sep 17 00:00:00 2001 From: skycel Date: Fri, 23 Jan 2026 00:07:23 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Feature:=20Router=20PHP=20+=20Pa?= =?UTF-8?q?ges=20projets=20(Stories=203.2=20&=203.3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Story 3.2 - Router PHP et URLs propres: - Router PHP léger (43 lignes) avec support {slug} - Front controller index.php - .htaccess pour Apache - Pages: home, projects, project-single, skills, about, contact, 404 Story 3.3 - Page liste projets vedettes: - Grille responsive (1→2→3 colonnes) - Template project-card.php réutilisable - Badges technologies (max 4 + compteur) - Lazy loading images avec fallback SVG Co-Authored-By: Claude Opus 4.5 --- .htaccess | 9 ++ assets/img/projects/default-project.svg | 4 + includes/router.php | 45 +++++++++ index.php | 116 +++--------------------- pages/404.php | 27 ++++++ pages/about.php | 31 +++++++ pages/contact.php | 31 +++++++ pages/home.php | 111 +++++++++++++++++++++++ pages/project-single.php | 40 ++++++++ pages/projects.php | 45 +++++++++ pages/skills.php | 31 +++++++ templates/project-card.php | 47 ++++++++++ 12 files changed, 432 insertions(+), 105 deletions(-) create mode 100644 .htaccess create mode 100644 assets/img/projects/default-project.svg create mode 100644 includes/router.php create mode 100644 pages/404.php create mode 100644 pages/about.php create mode 100644 pages/contact.php create mode 100644 pages/home.php create mode 100644 pages/project-single.php create mode 100644 pages/projects.php create mode 100644 pages/skills.php create mode 100644 templates/project-card.php diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..3c47a68 --- /dev/null +++ b/.htaccess @@ -0,0 +1,9 @@ +RewriteEngine On +RewriteBase / + +# Ne pas réécrire les fichiers et dossiers existants +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d + +# Rediriger tout vers index.php +RewriteRule ^(.*)$ index.php [QSA,L] diff --git a/assets/img/projects/default-project.svg b/assets/img/projects/default-project.svg new file mode 100644 index 0000000..675b4ee --- /dev/null +++ b/assets/img/projects/default-project.svg @@ -0,0 +1,4 @@ + + + Image à venir + diff --git a/includes/router.php b/includes/router.php new file mode 100644 index 0000000..7343b23 --- /dev/null +++ b/includes/router.php @@ -0,0 +1,45 @@ +routes[$regex] = $handler; + return $this; + } + + public function resolve(string $uri): array + { + $uri = parse_url($uri, PHP_URL_PATH); + $uri = rtrim($uri, '/') ?: '/'; + + foreach ($this->routes as $regex => $handler) { + if (preg_match($regex, $uri, $matches)) { + array_shift($matches); // Enlève le match complet + return [$handler, $matches]; + } + } + + return ['pages/404.php', []]; + } + + public function dispatch(): void + { + $uri = $_SERVER['REQUEST_URI'] ?? '/'; + [$handler, $params] = $this->resolve($uri); + + // Rend les paramètres accessibles + $GLOBALS['routeParams'] = $params; + + require __DIR__ . '/../' . $handler; + } +} diff --git a/index.php b/index.php index 9441378..00feacd 100644 --- a/index.php +++ b/index.php @@ -1,113 +1,19 @@ +$router + ->add('/', 'pages/home.php') + ->add('/projets', 'pages/projects.php') + ->add('/projet/{slug}', 'pages/project-single.php') + ->add('/competences', 'pages/skills.php') + ->add('/a-propos', 'pages/about.php') + ->add('/contact', 'pages/contact.php'); -
- -
-
- -

- Bonjour, je suis -

- - -

- Prénom NOM -

- - -

- Développeur Web Full-Stack -

- - -

- Je crée des expériences web modernes, performantes et accessibles. - Chaque projet est une opportunité de montrer plutôt que de dire. -

- - - -
-
- - -
- -
-
- - +$router->dispatch(); diff --git a/pages/404.php b/pages/404.php new file mode 100644 index 0000000..df6de5e --- /dev/null +++ b/pages/404.php @@ -0,0 +1,27 @@ + + +
+
+

404

+

+ Oups ! Cette page n'existe pas. +

+ + Retour à l'accueil + +
+
+ + diff --git a/pages/about.php b/pages/about.php new file mode 100644 index 0000000..d2dc536 --- /dev/null +++ b/pages/about.php @@ -0,0 +1,31 @@ + + +
+
+
+
+

À propos

+

+ Mon parcours et mes motivations +

+
+ +

+ Page en construction - Epic 4 +

+
+
+
+ + diff --git a/pages/contact.php b/pages/contact.php new file mode 100644 index 0000000..18fad88 --- /dev/null +++ b/pages/contact.php @@ -0,0 +1,31 @@ + + +
+
+
+
+

Contact

+

+ Discutons de votre projet +

+
+ +

+ Page en construction - Epic 5 +

+
+
+
+ + diff --git a/pages/home.php b/pages/home.php new file mode 100644 index 0000000..48f951c --- /dev/null +++ b/pages/home.php @@ -0,0 +1,111 @@ + + +
+ +
+
+ +

+ Bonjour, je suis +

+ + +

+ Prénom NOM +

+ + +

+ Développeur Web Full-Stack +

+ + +

+ Je crée des expériences web modernes, performantes et accessibles. + Chaque projet est une opportunité de montrer plutôt que de dire. +

+ + + +
+
+ + +
+ +
+
+ + diff --git a/pages/project-single.php b/pages/project-single.php new file mode 100644 index 0000000..72d0845 --- /dev/null +++ b/pages/project-single.php @@ -0,0 +1,40 @@ + + +
+
+
+
+

+

+ +

+
+ +

+ Page en construction - Story 3.4 +

+
+
+
+ + diff --git a/pages/projects.php b/pages/projects.php new file mode 100644 index 0000000..dc30794 --- /dev/null +++ b/pages/projects.php @@ -0,0 +1,45 @@ + + +
+ +
+
+
+

Mes Projets

+

+ Découvrez les réalisations qui illustrent mon travail et mes compétences. +

+
+ + + +
+ + $project]); ?> + +
+ +

+ Projets à venir... +

+ +
+
+ + +
+ + diff --git a/pages/skills.php b/pages/skills.php new file mode 100644 index 0000000..5ff9afb --- /dev/null +++ b/pages/skills.php @@ -0,0 +1,31 @@ + + +
+
+
+
+

Compétences

+

+ Technologies et outils maîtrisés +

+
+ +

+ Page en construction - Epic 4 +

+
+
+
+ + diff --git a/templates/project-card.php b/templates/project-card.php new file mode 100644 index 0000000..fa8600f --- /dev/null +++ b/templates/project-card.php @@ -0,0 +1,47 @@ + + +