Skip to content

Commit

Permalink
add new release v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bfoujols committed Aug 20, 2023
1 parent d4c63e1 commit 416b95a
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 52 deletions.
8 changes: 6 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ DB_HOST_STATUS=false
DB_HOST=127.0.0.1
DB_SOCKET=3306
DB_USER=root
DB_PASSWORD=
DB_PASSWORD=root
DB_NAME=app_db
## >> Config Database
## >> Config Database

## << Config préfixe des conteneurs Docker
APP_NAME=edu-framework
## >> Config préfixe des conteneurs Docker
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Managed by Composer
vendor/
var/
composer.phar
composer.lock

Expand Down
20 changes: 2 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
![separe](https://github.com/studoo-app/.github/blob/main/profile/studoo-banner-logo.png)
# edu-framework-skeleton
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/a15f20cbdf2743618efe54e2db39f605)](https://app.codacy.com/gh/studoo-app/edu-framework/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![Latest Stable Version](https://poser.pugx.org/studoo/edu-framework/v)](//packagist.org/packages/studoo/edu-framework)
[![Total Downloads](https://poser.pugx.org/studoo/edu-framework/downloads)](//packagist.org/packages/studoo/edu-framework)
[![Latest Unstable Version](https://poser.pugx.org/studoo/edu-framework/v/unstable)](//packagist.org/packages/edu-framework)
[![License](https://poser.pugx.org/studoo/edu-framework/license)](//packagist.org/packages/studoo/edu-framework)

Edu-Framework est une proposition d'architecture MVC pour la création de projets ou de travaux pratiques. L'objectif pédagogique est :
- Appréhender un projet par couche via MVC
- Faire un projet "full POO" et dans les "best practices" attendu par les entreprises
- Orchestrer via un gestionnaire de package (composer)
- Développement de test unitaire
- Début d'approche pour l'enseignement d'un framework (Symfony, Laravel ...)
## Bienvenu dans votre projet avec Edu-Framework

> [!NOTE]
> L'ensemble de la documentation est disponible sur le [https://edu-framework.studoo.app/](https://edu-framework.studoo.app/)
> [!IMPORTANT]
> Ce framework n'est pas adapté à une utilisation en production. Il est destiné à des fins pédagogiques.
> Pour installation et la configuration, voir -> [https://edu-framework.studoo.app/](https://edu-framework.studoo.app/)
6 changes: 4 additions & 2 deletions app/Controller/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
class HomeController implements ControllerInterface
{
/**
* @param Request $request Requête HTTP
* @return string|null
* @throws LoaderError
* @throws RuntimeError
* @throws SyntaxError
* @throws LoaderError
*/
public function execute(Request $request): string
public function execute(Request $request): string|null
{
return TwigCore::getEnvironment()->render('home/home.html.twig',
[
Expand Down
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
],
"edu:init": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
]
],
"edu:docker:db-service:start": "Studoo\\EduFramework\\Scripts\\DockerPilot::start",
"edu:docker:db-service:down": "Studoo\\EduFramework\\Scripts\\DockerPilot::down"
},
"scripts-descriptions": {
"edu:init": "Create env file",
"edu:start": "Start local server",
"edu:docker:db-service:start": "Start docker related database service [args : mysql / maria-db]",
"edu:docker:db-service:down": "Stop and remove docker related database service [args : mysql / maria-db]"
}
}
42 changes: 42 additions & 0 deletions docker/docker-compose-maria-db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: "3.8"
services:
##########################
# CONTENEURS SERVICES #
##########################

#Base de données Mysql
database:
container_name: ${APP_NAME}-db
image: mariadb:10.5.8
restart: always
ports:
- "3306:3306"
volumes:
- ../var/db-data:/var/lib/mysql
environment:
#MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
MYSQL_DATABASE: ${DB_NAME}
#MYSQL_USER: app_db_user
#MYSQL_PASSWORD: app_db_password
networks:
- dev
#PHP My Admin
phpmyadmin:
container_name: ${APP_NAME}-pma
image: phpmyadmin:latest
restart: always
depends_on:
- database
ports:
- "8081:80"
environment:
PMA_HOST: db
networks:
- dev
#Network
networks:
dev:
#Volumes
volumes:
db-data:
37 changes: 37 additions & 0 deletions docker/docker-compose-mysql-5.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: "3.8"
services:

database:
container_name: ${APP_NAME}-database
image: mysql:5.7
platform: linux/amd64
ports:
- "3306:3306"
restart: always
environment:
#MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
MYSQL_DATABASE: ${DB_NAME}
#MYSQL_USER: app_db_user
#MYSQL_PASSWORD: app_db_password
volumes:
- ../var/dbdata:/var/lib/mysql
#PHP My Admin
phpmyadmin:
container_name: ${APP_NAME}-pma
image: phpmyadmin:latest
restart: always
depends_on:
- database
ports:
- "8081:80"
environment:
PMA_HOST: db
networks:
- dev
#Network
networks:
dev:
#Volumes
volumes:
db-data:
53 changes: 24 additions & 29 deletions public/index.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
<?php
// Démarrage de la session PHP pour la gestion des variables de session
use Studoo\EduFramework\Core\ConfigCore;
use Studoo\EduFramework\Core\LoadCouchCore;

// Autoloader => chargement automatique des classes depuis le dossier vendor/
require_once __DIR__ . '/../vendor/autoload.php';
session_start();

// Utilisation des classes utilisées dans le fichier
use Controller\HomeController;
use Dotenv\Dotenv;
use Studoo\EduFramework\Core\Controller\FastRouteCore;
use Studoo\EduFramework\Core\Service\DatabaseService;
use Studoo\EduFramework\Core\View\TwigCore;
// Masquer les deprecations de PHP 8.1
error_reporting(E_ALL & ~E_DEPRECATED);

// Gestion des fichiers environnement .env
$dotenv = Dotenv::createImmutable(__DIR__ . "/../");
$dotenv->load();
if (version_compare(PHP_VERSION, '8.0', '<') === false) {
// Autoloader => chargement automatique des classes depuis le dossier vendor/
require_once __DIR__ . '/../vendor/autoload.php';

// Gestion de la couche View
(new TwigCore(__DIR__ . '/../app/Template'));
$en = TwigCore::getEnvironment();
// Chargement des configurations de l'application
(new ConfigCore(
[
'base_path' => __DIR__ . '/../',
'twig_path' => __DIR__ . '/../app/Template',
'route_config_path' => __DIR__ . '/../app/config/'
]
)
);

// Gestion de la couche Model et de la connexion à la base de données
if ($_ENV['DB_HOST_STATUS'] === 'true') {
(new DatabaseService());
}

// Gestion des routes
$route = new FastRouteCore();
// Load des routes depuis le fichier de configuration
$route->loadRouteConfig(__DIR__ . '/../app/config/');

// Récupération de la route à appeler
try {
echo $route->getRoute();
} catch (\Twig\Error\LoaderError|\Twig\Error\RuntimeError|\Twig\Error\SyntaxError|Exception $e) {
echo $e->getMessage();
// Chargement des classes utilisées par l'application
(new LoadCouchCore())->run();
} else {
echo "Cet app nécessite au moins PHP8.0. "
. PHP_VERSION .
" est actuellement installé. Veuillez mettre à jour votre version de PHP.\n";
}

0 comments on commit 416b95a

Please sign in to comment.