Răsfoiți Sursa

Ajout du sujet de 2018

akrah 6 ani în urmă
părinte
comite
fca07a7501
37 a modificat fișierele cu 1106 adăugiri și 0 ștergeri
  1. 14 0
      TP-note-2018/ParcInfo/.env.example
  2. 5 0
      TP-note-2018/ParcInfo/.gitignore
  3. 0 0
      TP-note-2018/ParcInfo/app/Console/Commands/.gitkeep
  4. 29 0
      TP-note-2018/ParcInfo/app/Console/Kernel.php
  5. 10 0
      TP-note-2018/ParcInfo/app/Events/Event.php
  6. 16 0
      TP-note-2018/ParcInfo/app/Events/ExampleEvent.php
  7. 50 0
      TP-note-2018/ParcInfo/app/Exceptions/Handler.php
  8. 10 0
      TP-note-2018/ParcInfo/app/Http/Controllers/Controller.php
  9. 18 0
      TP-note-2018/ParcInfo/app/Http/Controllers/ExampleController.php
  10. 44 0
      TP-note-2018/ParcInfo/app/Http/Middleware/Authenticate.php
  11. 20 0
      TP-note-2018/ParcInfo/app/Http/Middleware/ExampleMiddleware.php
  12. 26 0
      TP-note-2018/ParcInfo/app/Jobs/ExampleJob.php
  13. 24 0
      TP-note-2018/ParcInfo/app/Jobs/Job.php
  14. 31 0
      TP-note-2018/ParcInfo/app/Listeners/ExampleListener.php
  15. 13 0
      TP-note-2018/ParcInfo/app/Models/Model_Base.php
  16. 18 0
      TP-note-2018/ParcInfo/app/Providers/AppServiceProvider.php
  17. 39 0
      TP-note-2018/ParcInfo/app/Providers/AuthServiceProvider.php
  18. 19 0
      TP-note-2018/ParcInfo/app/Providers/EventServiceProvider.php
  19. 32 0
      TP-note-2018/ParcInfo/app/User.php
  20. 35 0
      TP-note-2018/ParcInfo/artisan
  21. 102 0
      TP-note-2018/ParcInfo/bootstrap/app.php
  22. 36 0
      TP-note-2018/ParcInfo/composer.json
  23. 27 0
      TP-note-2018/ParcInfo/phpunit.xml
  24. 20 0
      TP-note-2018/ParcInfo/public/.htaccess
  25. 28 0
      TP-note-2018/ParcInfo/public/index.php
  26. 21 0
      TP-note-2018/ParcInfo/readme.md
  27. 0 0
      TP-note-2018/ParcInfo/resources/views/.gitkeep
  28. 85 0
      TP-note-2018/ParcInfo/routes/web.php
  29. 2 0
      TP-note-2018/ParcInfo/storage/app/.gitignore
  30. 2 0
      TP-note-2018/ParcInfo/storage/framework/cache/.gitignore
  31. 2 0
      TP-note-2018/ParcInfo/storage/framework/views/.gitignore
  32. 2 0
      TP-note-2018/ParcInfo/storage/logs/.gitignore
  33. 21 0
      TP-note-2018/ParcInfo/tests/ExampleTest.php
  34. 14 0
      TP-note-2018/ParcInfo/tests/TestCase.php
  35. 58 0
      TP-note-2018/Preparation.md
  36. 109 0
      TP-note-2018/README.md
  37. 124 0
      TP-note-2018/init_db.sql

+ 14 - 0
TP-note-2018/ParcInfo/.env.example

@@ -0,0 +1,14 @@
+APP_ENV=local
+APP_DEBUG=true
+APP_KEY=
+APP_TIMEZONE=UTC
+
+DB_CONNECTION=mysql
+DB_HOST=127.0.0.1
+DB_PORT=3306
+DB_DATABASE=homestead
+DB_USERNAME=homestead
+DB_PASSWORD=secret
+
+CACHE_DRIVER=file
+QUEUE_DRIVER=sync

+ 5 - 0
TP-note-2018/ParcInfo/.gitignore

@@ -0,0 +1,5 @@
+/vendor
+/.idea
+Homestead.json
+Homestead.yaml
+.env

+ 0 - 0
TP-note-2018/ParcInfo/app/Console/Commands/.gitkeep


+ 29 - 0
TP-note-2018/ParcInfo/app/Console/Kernel.php

@@ -0,0 +1,29 @@
+<?php
+
+namespace App\Console;
+
+use Illuminate\Console\Scheduling\Schedule;
+use Laravel\Lumen\Console\Kernel as ConsoleKernel;
+
+class Kernel extends ConsoleKernel
+{
+    /**
+     * The Artisan commands provided by your application.
+     *
+     * @var array
+     */
+    protected $commands = [
+        //
+    ];
+
+    /**
+     * Define the application's command schedule.
+     *
+     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
+     * @return void
+     */
+    protected function schedule(Schedule $schedule)
+    {
+        //
+    }
+}

+ 10 - 0
TP-note-2018/ParcInfo/app/Events/Event.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Events;
+
+use Illuminate\Queue\SerializesModels;
+
+abstract class Event
+{
+    use SerializesModels;
+}

+ 16 - 0
TP-note-2018/ParcInfo/app/Events/ExampleEvent.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Events;
+
+class ExampleEvent extends Event
+{
+    /**
+     * Create a new event instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+}

+ 50 - 0
TP-note-2018/ParcInfo/app/Exceptions/Handler.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace App\Exceptions;
+
+use Exception;
+use Illuminate\Validation\ValidationException;
+use Illuminate\Auth\Access\AuthorizationException;
+use Illuminate\Database\Eloquent\ModelNotFoundException;
+use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
+use Symfony\Component\HttpKernel\Exception\HttpException;
+
+class Handler extends ExceptionHandler
+{
+    /**
+     * A list of the exception types that should not be reported.
+     *
+     * @var array
+     */
+    protected $dontReport = [
+        AuthorizationException::class,
+        HttpException::class,
+        ModelNotFoundException::class,
+        ValidationException::class,
+    ];
+
+    /**
+     * Report or log an exception.
+     *
+     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
+     *
+     * @param  \Exception  $e
+     * @return void
+     */
+    public function report(Exception $e)
+    {
+        parent::report($e);
+    }
+
+    /**
+     * Render an exception into an HTTP response.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \Exception  $e
+     * @return \Illuminate\Http\Response
+     */
+    public function render($request, Exception $e)
+    {
+        return parent::render($request, $e);
+    }
+}

+ 10 - 0
TP-note-2018/ParcInfo/app/Http/Controllers/Controller.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Laravel\Lumen\Routing\Controller as BaseController;
+
+class Controller extends BaseController
+{
+    //
+}

+ 18 - 0
TP-note-2018/ParcInfo/app/Http/Controllers/ExampleController.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace App\Http\Controllers;
+
+class ExampleController extends Controller
+{
+    /**
+     * Create a new controller instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    //
+}

+ 44 - 0
TP-note-2018/ParcInfo/app/Http/Middleware/Authenticate.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Closure;
+use Illuminate\Contracts\Auth\Factory as Auth;
+
+class Authenticate
+{
+    /**
+     * The authentication guard factory instance.
+     *
+     * @var \Illuminate\Contracts\Auth\Factory
+     */
+    protected $auth;
+
+    /**
+     * Create a new middleware instance.
+     *
+     * @param  \Illuminate\Contracts\Auth\Factory  $auth
+     * @return void
+     */
+    public function __construct(Auth $auth)
+    {
+        $this->auth = $auth;
+    }
+
+    /**
+     * Handle an incoming request.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \Closure  $next
+     * @param  string|null  $guard
+     * @return mixed
+     */
+    public function handle($request, Closure $next, $guard = null)
+    {
+        if ($this->auth->guard($guard)->guest()) {
+            return response('Unauthorized.', 401);
+        }
+
+        return $next($request);
+    }
+}

+ 20 - 0
TP-note-2018/ParcInfo/app/Http/Middleware/ExampleMiddleware.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Closure;
+
+class ExampleMiddleware
+{
+    /**
+     * Handle an incoming request.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \Closure  $next
+     * @return mixed
+     */
+    public function handle($request, Closure $next)
+    {
+        return $next($request);
+    }
+}

+ 26 - 0
TP-note-2018/ParcInfo/app/Jobs/ExampleJob.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Jobs;
+
+class ExampleJob extends Job
+{
+    /**
+     * Create a new job instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+        //
+    }
+}

+ 24 - 0
TP-note-2018/ParcInfo/app/Jobs/Job.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Jobs;
+
+use Illuminate\Bus\Queueable;
+use Illuminate\Queue\SerializesModels;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Contracts\Queue\ShouldQueue;
+
+abstract class Job implements ShouldQueue
+{
+    /*
+    |--------------------------------------------------------------------------
+    | Queueable Jobs
+    |--------------------------------------------------------------------------
+    |
+    | This job base class provides a central location to place any logic that
+    | is shared across all of your jobs. The trait included with the class
+    | provides access to the "queueOn" and "delay" queue helper methods.
+    |
+    */
+
+    use InteractsWithQueue, Queueable, SerializesModels;
+}

+ 31 - 0
TP-note-2018/ParcInfo/app/Listeners/ExampleListener.php

@@ -0,0 +1,31 @@
+<?php
+
+namespace App\Listeners;
+
+use App\Events\ExampleEvent;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Contracts\Queue\ShouldQueue;
+
+class ExampleListener
+{
+    /**
+     * Create the event listener.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * Handle the event.
+     *
+     * @param  ExampleEvent  $event
+     * @return void
+     */
+    public function handle(ExampleEvent $event)
+    {
+        //
+    }
+}

+ 13 - 0
TP-note-2018/ParcInfo/app/Models/Model_Base.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Models;
+use PDO;
+
+class Model_Base
+{
+	protected static $_db;
+
+	public static function set_db(PDO $db) {
+		self::$_db = $db;
+	}
+}

+ 18 - 0
TP-note-2018/ParcInfo/app/Providers/AppServiceProvider.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace App\Providers;
+
+use Illuminate\Support\ServiceProvider;
+
+class AppServiceProvider extends ServiceProvider
+{
+    /**
+     * Register any application services.
+     *
+     * @return void
+     */
+    public function register()
+    {
+        //
+    }
+}

+ 39 - 0
TP-note-2018/ParcInfo/app/Providers/AuthServiceProvider.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace App\Providers;
+
+use App\User;
+use Illuminate\Support\Facades\Gate;
+use Illuminate\Support\ServiceProvider;
+
+class AuthServiceProvider extends ServiceProvider
+{
+    /**
+     * Register any application services.
+     *
+     * @return void
+     */
+    public function register()
+    {
+        //
+    }
+
+    /**
+     * Boot the authentication services for the application.
+     *
+     * @return void
+     */
+    public function boot()
+    {
+        // Here you may define how you wish users to be authenticated for your Lumen
+        // application. The callback which receives the incoming request instance
+        // should return either a User instance or null. You're free to obtain
+        // the User instance via an API token or any other method necessary.
+
+        $this->app['auth']->viaRequest('api', function ($request) {
+            if ($request->input('api_token')) {
+                return User::where('api_token', $request->input('api_token'))->first();
+            }
+        });
+    }
+}

+ 19 - 0
TP-note-2018/ParcInfo/app/Providers/EventServiceProvider.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Providers;
+
+use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider;
+
+class EventServiceProvider extends ServiceProvider
+{
+    /**
+     * The event listener mappings for the application.
+     *
+     * @var array
+     */
+    protected $listen = [
+        'App\Events\SomeEvent' => [
+            'App\Listeners\EventListener',
+        ],
+    ];
+}

+ 32 - 0
TP-note-2018/ParcInfo/app/User.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace App;
+
+use Illuminate\Auth\Authenticatable;
+use Laravel\Lumen\Auth\Authorizable;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
+use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
+
+class User extends Model implements AuthenticatableContract, AuthorizableContract
+{
+    use Authenticatable, Authorizable;
+
+    /**
+     * The attributes that are mass assignable.
+     *
+     * @var array
+     */
+    protected $fillable = [
+        'name', 'email',
+    ];
+
+    /**
+     * The attributes excluded from the model's JSON form.
+     *
+     * @var array
+     */
+    protected $hidden = [
+        'password',
+    ];
+}

+ 35 - 0
TP-note-2018/ParcInfo/artisan

@@ -0,0 +1,35 @@
+#!/usr/bin/env php
+<?php
+
+use Symfony\Component\Console\Input\ArgvInput;
+use Symfony\Component\Console\Output\ConsoleOutput;
+
+/*
+|--------------------------------------------------------------------------
+| Create The Application
+|--------------------------------------------------------------------------
+|
+| First we need to get an application instance. This creates an instance
+| of the application / container and bootstraps the application so it
+| is ready to receive HTTP / Console requests from the environment.
+|
+*/
+
+$app = require __DIR__.'/bootstrap/app.php';
+
+/*
+|--------------------------------------------------------------------------
+| Run The Artisan Application
+|--------------------------------------------------------------------------
+|
+| When we run the console application, the current CLI command will be
+| executed in this console and the response sent back to a terminal
+| or another output device for the developers. Here goes nothing!
+|
+*/
+
+$kernel = $app->make(
+    'Illuminate\Contracts\Console\Kernel'
+);
+
+exit($kernel->handle(new ArgvInput, new ConsoleOutput));

+ 102 - 0
TP-note-2018/ParcInfo/bootstrap/app.php

@@ -0,0 +1,102 @@
+<?php
+
+require_once __DIR__.'/../vendor/autoload.php';
+
+try {
+    (new Dotenv\Dotenv(__DIR__.'/../'))->load();
+} catch (Dotenv\Exception\InvalidPathException $e) {
+    //
+}
+
+/*
+|--------------------------------------------------------------------------
+| Create The Application
+|--------------------------------------------------------------------------
+|
+| Here we will load the environment and create the application instance
+| that serves as the central piece of this framework. We'll use this
+| application as an "IoC" container and router for this framework.
+|
+*/
+
+$app = new Laravel\Lumen\Application(
+    realpath(__DIR__.'/../')
+);
+
+// $app->withFacades();
+
+// $app->withEloquent();
+
+/*
+|--------------------------------------------------------------------------
+| Register Container Bindings
+|--------------------------------------------------------------------------
+|
+| Now we will register a few bindings in the service container. We will
+| register the exception handler and the console kernel. You may add
+| your own bindings here if you like or you can make another file.
+|
+*/
+
+$app->singleton(
+    Illuminate\Contracts\Debug\ExceptionHandler::class,
+    App\Exceptions\Handler::class
+);
+
+$app->singleton(
+    Illuminate\Contracts\Console\Kernel::class,
+    App\Console\Kernel::class
+);
+
+/*
+|--------------------------------------------------------------------------
+| Register Middleware
+|--------------------------------------------------------------------------
+|
+| Next, we will register the middleware with the application. These can
+| be global middleware that run before and after each request into a
+| route or middleware that'll be assigned to some specific routes.
+|
+*/
+
+// $app->middleware([
+//    App\Http\Middleware\ExampleMiddleware::class
+// ]);
+
+// $app->routeMiddleware([
+//      'auth' => App\Http\Middleware\Authenticate::class,
+// ]);
+
+/*
+|--------------------------------------------------------------------------
+| Register Service Providers
+|--------------------------------------------------------------------------
+|
+| Here we will register all of the application's service providers which
+| are used to bind services into the container. Service providers are
+| totally optional, so you are not required to uncomment this line.
+|
+*/
+
+// $app->register(App\Providers\AppServiceProvider::class);
+// $app->register(App\Providers\AuthServiceProvider::class);
+// $app->register(App\Providers\EventServiceProvider::class);
+
+/*
+|--------------------------------------------------------------------------
+| Load The Application Routes
+|--------------------------------------------------------------------------
+|
+| Next we will include the routes file so that they can all be added to
+| the application. This will provide all of the URLs the application
+| can respond to, as well as the controllers that may handle them.
+|
+*/
+
+$app->router->group([
+    'namespace' => 'App\Http\Controllers',
+], function ($router) {
+    require __DIR__.'/../routes/web.php';
+});
+
+return $app;

+ 36 - 0
TP-note-2018/ParcInfo/composer.json

@@ -0,0 +1,36 @@
+{
+    "name": "laravel/lumen",
+    "description": "The Laravel Lumen Framework.",
+    "keywords": ["framework", "laravel", "lumen"],
+    "license": "MIT",
+    "type": "project",
+    "require": {
+        "php": ">=5.6.4",
+        "laravel/lumen-framework": "5.5.*",
+        "vlucas/phpdotenv": "~2.2"
+    },
+    "require-dev": {
+        "fzaninotto/faker": "~1.4",
+        "phpunit/phpunit": "~6.0",
+        "mockery/mockery": "~0.9"
+    },
+    "autoload": {
+        "psr-4": {
+            "App\\": "app/"
+        }
+    },
+    "autoload-dev": {
+        "classmap": [
+            "tests/",
+            "database/"
+        ]
+    },
+    "scripts": {
+        "post-root-package-install": [
+            "php -r \"copy('.env.example', '.env');\""
+        ]
+    },
+    "minimum-stability": "dev",
+    "prefer-stable": true,
+    "optimize-autoloader": true
+}

+ 27 - 0
TP-note-2018/ParcInfo/phpunit.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit backupGlobals="false"
+         backupStaticAttributes="false"
+         bootstrap="bootstrap/app.php"
+         colors="true"
+         convertErrorsToExceptions="true"
+         convertNoticesToExceptions="true"
+         convertWarningsToExceptions="true"
+         processIsolation="false"
+         stopOnFailure="false"
+         syntaxCheck="false">
+    <testsuites>
+        <testsuite name="Application Test Suite">
+            <directory suffix="Test.php">./tests</directory>
+        </testsuite>
+    </testsuites>
+    <filter>
+        <whitelist processUncoveredFilesFromWhitelist="true">
+            <directory suffix=".php">./app</directory>
+        </whitelist>
+    </filter>
+    <php>
+        <env name="APP_ENV" value="testing"/>
+        <env name="CACHE_DRIVER" value="array"/>
+        <env name="QUEUE_DRIVER" value="sync"/>
+    </php>
+</phpunit>

+ 20 - 0
TP-note-2018/ParcInfo/public/.htaccess

@@ -0,0 +1,20 @@
+<IfModule mod_rewrite.c>
+    <IfModule mod_negotiation.c>
+        Options -MultiViews
+    </IfModule>
+
+    RewriteEngine On
+
+    # Redirect Trailing Slashes If Not A Folder...
+    RewriteCond %{REQUEST_FILENAME} !-d
+    RewriteRule ^(.*)/$ /$1 [L,R=301]
+
+    # Handle Front Controller...
+    RewriteCond %{REQUEST_FILENAME} !-d
+    RewriteCond %{REQUEST_FILENAME} !-f
+    RewriteRule ^ index.php [L]
+
+    # Handle Authorization Header
+    RewriteCond %{HTTP:Authorization} .
+    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
+</IfModule>

+ 28 - 0
TP-note-2018/ParcInfo/public/index.php

@@ -0,0 +1,28 @@
+<?php
+
+/*
+|--------------------------------------------------------------------------
+| Create The Application
+|--------------------------------------------------------------------------
+|
+| First we need to get an application instance. This creates an instance
+| of the application / container and bootstraps the application so it
+| is ready to receive HTTP / Console requests from the environment.
+|
+*/
+
+$app = require __DIR__.'/../bootstrap/app.php';
+
+/*
+|--------------------------------------------------------------------------
+| Run The Application
+|--------------------------------------------------------------------------
+|
+| Once we have the application, we can handle the incoming request
+| through the kernel, and send the associated response back to
+| the client's browser allowing them to enjoy the creative
+| and wonderful application we have prepared for them.
+|
+*/
+
+$app->run();

+ 21 - 0
TP-note-2018/ParcInfo/readme.md

@@ -0,0 +1,21 @@
+# Lumen PHP Framework
+
+[![Build Status](https://travis-ci.org/laravel/lumen-framework.svg)](https://travis-ci.org/laravel/lumen-framework)
+[![Total Downloads](https://poser.pugx.org/laravel/lumen-framework/d/total.svg)](https://packagist.org/packages/laravel/lumen-framework)
+[![Latest Stable Version](https://poser.pugx.org/laravel/lumen-framework/v/stable.svg)](https://packagist.org/packages/laravel/lumen-framework)
+[![Latest Unstable Version](https://poser.pugx.org/laravel/lumen-framework/v/unstable.svg)](https://packagist.org/packages/laravel/lumen-framework)
+[![License](https://poser.pugx.org/laravel/lumen-framework/license.svg)](https://packagist.org/packages/laravel/lumen-framework)
+
+Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Lumen attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as routing, database abstraction, queueing, and caching.
+
+## Official Documentation
+
+Documentation for the framework can be found on the [Lumen website](http://lumen.laravel.com/docs).
+
+## Security Vulnerabilities
+
+If you discover a security vulnerability within Lumen, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed.
+
+## License
+
+The Lumen framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

+ 0 - 0
TP-note-2018/ParcInfo/resources/views/.gitkeep


+ 85 - 0
TP-note-2018/ParcInfo/routes/web.php

@@ -0,0 +1,85 @@
+<?php
+
+/*
+|--------------------------------------------------------------------------
+| Application Routes
+|--------------------------------------------------------------------------
+|
+| Here is where you can register all of the routes for an application.
+| It is a breeze. Simply tell Lumen the URIs it should respond to
+| and give it the Closure to call when that URI is requested.
+|
+*/
+
+// Partie publique ------------------------------------------------------------
+
+// Racine
+$router->get('/', function () { return view('signin'); });
+
+// Connexion
+$router->get( 'signin', function () { return view('signin'); });
+$router->post('signin', function () { return redirect('signin'); });
+$router->get( 'authenticate', function () { return redirect('signin'); });
+$router->post('authenticate',
+    ['middleware' => 'session', 'uses' => 'UserController@authenticate'] );
+
+// Inscription
+$router->get( 'signup', function () { return view('signup'); });
+$router->post('signup', function () { return redirect('signup'); });
+$router->get( 'adduser', function () { return redirect('signup'); });
+$router->post('adduser',
+    ['middleware' => 'session', 'uses' => 'UserController@adduser'] );
+
+// Partie account -------------------------------------------------------------
+
+$router->group(
+    ['prefix' => 'account','middleware' => 'session'],
+    function () use ($router) {
+        // Déconnexion
+        $router->get('signout', ['uses' => 'UserController@signout']);
+
+        // Page d'accueil
+        $router->get ('/',       function () { return view('welcome'); });
+        $router->get ('welcome', function () { return view('welcome'); });
+        $router->post('welcome', function () { return redirect('signin'); });
+
+        // Changement du mot de passe
+        $router->get ('formpassword', function () { return view('formpassword'); });
+        $router->post('formpassword', function () { return redirect('signin'); });
+        $router->get ('changepassword', function () { return redirect('formpassword'); });
+        $router->post('changepassword', ['uses' => 'UserController@changePassword']);
+
+        // Supprimer mon compte
+        $router->get ('deleteuser', ['uses' => 'UserController@deleteUser']);
+        $router->post('deleteuser', function () { return redirect('welcome'); });
+
+        //=====================================================================
+
+        $router->get ('managepostes', function() { return view('managepostes'); });
+        $router->post('managepostes', function() { return redirect('managepostes'); });
+
+        $router->get ('allpostes', ['uses' => 'PostesController@allPostes']);
+        $router->post('allpostes', function() { return redirect('managepostes'); });
+
+        $router->get ('ajouterposte', function() { return view('formajouterposte'); });
+        $router->post('ajouterposte', ['uses' => 'PostesController@ajouterPoste']);
+
+        $router->get ('supprimerposte/{id}', ['uses' => 'PostesController@supprimerPoste']);
+        $router->post('supprimerposte', function() { return redirect('managepostes'); });
+
+        $router->get ('allreservations', ['uses' => 'ReservationsController@allReservations']);
+        $router->post('allreservations', function() { return redirect('managepostes'); });
+
+        $router->get ('ajouterreservation', function() { return view('formajouterreservation'); });
+        $router->post('ajouterreservation', ['uses' => 'ReservationsController@ajouterReservation']);
+
+        $router->get ('supprimerreservation/{id}', ['uses' => 'ReservationsController@supprimerReservation']);
+        $router->post('supprimerreservation', function() { return redirect('managepostes'); });
+
+        $router->get ('reservations/{id}', ['uses' => 'ReservationsController@duPoste']);
+        $router->post('reservations/{id}', function() { return redirect('managepostes'); });
+
+        $router->get ('mypostes', ['uses' => 'PostesController@userPostes']);
+        $router->post('mypostes', function() { return redirect('managepostes'); });
+    }
+);

+ 2 - 0
TP-note-2018/ParcInfo/storage/app/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 2 - 0
TP-note-2018/ParcInfo/storage/framework/cache/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 2 - 0
TP-note-2018/ParcInfo/storage/framework/views/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 2 - 0
TP-note-2018/ParcInfo/storage/logs/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 21 - 0
TP-note-2018/ParcInfo/tests/ExampleTest.php

@@ -0,0 +1,21 @@
+<?php
+
+use Laravel\Lumen\Testing\DatabaseMigrations;
+use Laravel\Lumen\Testing\DatabaseTransactions;
+
+class ExampleTest extends TestCase
+{
+    /**
+     * A basic test example.
+     *
+     * @return void
+     */
+    public function testExample()
+    {
+        $this->get('/');
+
+        $this->assertEquals(
+            $this->app->version(), $this->response->getContent()
+        );
+    }
+}

+ 14 - 0
TP-note-2018/ParcInfo/tests/TestCase.php

@@ -0,0 +1,14 @@
+<?php
+
+abstract class TestCase extends Laravel\Lumen\Testing\TestCase
+{
+    /**
+     * Creates the application.
+     *
+     * @return \Laravel\Lumen\Application
+     */
+    public function createApplication()
+    {
+        return require __DIR__.'/../bootstrap/app.php';
+    }
+}

+ 58 - 0
TP-note-2018/Preparation.md

@@ -0,0 +1,58 @@
+Bonjour,
+
+Ci-dessous quelques informations générales à propos du TP noté de lundi.
+
+Organisation
+------------
+
+- Vous serez répartis sur les salles 5, 17 , 105 et 106.
+- La répartition par salle sera affichée à l'entrée et sur chaque salle
+- Vous aurez le droit de (et êtes même encouragés à) utiliser votre ordinateur personnel : il n'y aura pas de poste fixe pour tout le monde.
+- Bien entendu, tous les autres appareils électroniques seront rangés dans vos sacs et vos téléphones en silencieux.
+
+BDD
+---
+
+Nous vous fourniront un script MySQL à importer dans PhpMyAdmin qui contiendra le modèle de BDD avec des données déjà insérées. Vous pouvez tester cette procédure avec le fichier d'exemple fournit en pièce jointe et en suivant par exemple la procédure ici : https://help.fasthosts.co.uk/app/answers/detail/a_id/3186/~/importing-and-exporting-mysql-databases-using-phpmyadmin
+(vous trouverez pleins d'autres exemples sur internet).
+
+Gitlab
+------
+
+Le sujet du TP noté sera "pushé" sur le remote "prof" lundi à 8h30. Vous pourrez donc le récupérer de la même manière que vous avez récupéré les sujet des TPs tout au long du module.
+
+À faire dès à présent :
+
+- Donnez les droits "Reporter" sur votre clone à votre chargé de TD
+- Mettre votre clone en privé limiter le plagiat
+
+À faire pendant l'examen :
+
+- Faites un `git pull prof master` pour récupérer le sujet
+- Faites des `git commit` régulièrement : il pourront servir de base pour dissocier les éventuels plagiaires des plagiés.
+- ne faites qu'un seul `git push origin master` à la fin
+- vous aurez droit à toutes les aides possibles : code, internet, etc... à l'exception de l'aide directe d'autres personnes, qu'elles soient présentes physiquement ou en ligne.
+- vous pourrez utiliser toutes les fonctionnalités de Lumen que vous voulez mais seules celles vues en cours, TDs et TPs seront nécessaires : en utiliser de plus avancées ne donnera pas plus de points.
+
+
+Principaux aspects à maîtriser
+------------------------------
+
+- Syntaxe PHP
+- Connexion à une basse de donnée avec PDO (et/ou Eloquent)
+- Organisation MVC de votre code
+- Répartition des tâches selon le modèle MVC :
+    - routage dans web.php
+    - requêtes vers la BDD exclusivement dans les classes Modèle
+    - traitement des requêtes et utilisation des classes Modèles pour générer les vues dans les contrôleurs
+    - middleware pour des tâches répétitives et/ou de contrôle
+- Cohérence des requêtes avec leur traitement
+- Routage :
+    - utilisation de prefixes
+    - utilisation de paramètres transmis aux contrôleurs
+- Blade :
+    - utilisation d'un ou plusieurs layouts avec héritage
+    - traitement de paramètres transmis par les contrôleurs
+
+
+Bon week-end.

+ 109 - 0
TP-note-2018/README.md

@@ -0,0 +1,109 @@
+TP noté
+=======
+
+## Contexte
+
+La startup dans laquelle vous venez d'être recruté s'agrandit et il devient primordial de mettre en place une **gestion mutualisée du parc informatique**.
+C'est en partie pour vos compétences en développement web que vous avez tapé dans l'œil de votre chef de projet : votre première mission consiste à concevoir une application back-end (partie serveur) Lumen avec un front-end (site web) minimaliste pour la gestion du parc informatique, répondant au cahier des charges qui suit.
+
+
+## Rendu
+
+- Pensez à "commiter" au fur et à mesure du TP
+- Ne "pusher" l'ensemble de votre code sur Gitlab qu'au moment où vous terminez.
+- Attention, **seul les commits effectués AVANT la fin de la séance seront pris en compte** : pensez à prendre le temps nécessaire à ces opération avant la fin de l'examen.
+
+
+## Évaluation
+
+- L'évaluation ne tiendra pas compte de la qualité de l'interface et de l'ergonomie : concentrez-vous sur le PHP, pas sur le HTML.
+- Les intentions seront prises en compte : si vous savez comment faire mais êtes bloqués par un problème technique, signalez-le par un commentaire et passez aux autres fonctionnalités.
+
+
+## Base de données
+
+Le modèle de données utilisé doit être composé des 3 tables suivantes :
+
+- `Users`  : login (varchar,255), password (varchar,255)`
+- `Postes` : id (int,11), salle (int,3), os (varchar,255)`
+- `Reservations` : id (int,11), user_id (varchar,255), poste_id (int,11), date_debut (date), date_fin (date), est_root (tinyint,1)`
+
+Dans la table `Users` :
+
+- la colonne `login` est la clé primaire et unique de la table `Users`
+
+Dans la table `Reservations` :
+
+- les colonnes `user_id` et `poste_id` sont des clés étrangères référençant les colonnes `login` et `id` des tables `Users` et `Postes`.
+- la colonne `est_root` est un booléen indiquant si l'utilisateur est administrateur ou non.
+- Les colonnes `date_debut` et `date_fin` définissent la période sur laquelle un utilisateur est autorisé à utiliser un poste.
+- Pour la colonne `est_root`, le type `(tinyint,1)` est identique à un booléen
+
+Le fichier `init_db.sql` contient un script SQL permettant de créer ces tables avec leurs contraintes et des enregistrements. Il doit être importé dans PhpMyAdmin selon les indications ci-dessous.
+
+
+## Démarrer le TP
+
+1. Exécutez la commande le `git pull prof master` pour récupérer le répertoire `TP_note` qui contient :
+	- `ParcInfo/` : le répertoire contenant le framework lumen de base.
+	- `init_db.sql` : le script d'initialisation de la base de données
+	- `README.md` : l'énoncé du TP noté que vous êtes en train de lire.
+
+2. Importez la base de données dans PhpMyAdmin :
+	- Créez une nouvelle base de données `ParcInfo` depuis http://ss4s.iutrs.unistra.fr
+	- Connectez-vous sur PhpMyAdmin à l'adresse http://webetu.iutrs.unistra.fr/phpmyadmin/
+	- Suivez [cette procédure](https://help.fasthosts.co.uk/app/answers/detail/a_id/3186/~/importing-and-exporting-mysql-databases-using-phpmyadmin) en
+	choisissant sélectionnant la base `ParcInfo` et le script `init_db.sql` comme fichier à importer.
+
+3. Modifiez le fichier `ParcInfo/.env` avec vos informations de connexion à la base de données.
+
+4. Copiez-collez le répertoire `vendor` de l'un de vos projet Lumen, ainsi que tous les autres fichiers que vous voulez.
+
+5. Votre environnement est prêt.
+
+## Fonctionnalités à implémenter
+
+[Un site d'exemple est accessible ici](http://adrien.krahenbuhl.fr/courses/IUTRS/W31/TP-note-mockup/) : attention, tous les liens et les boutons d'envoi de formulaires sont de simples appels à des pages HTML statiques. Les actions d'ajout, de suppression et de modification son inopérantes. Pas besoin de compte pour se connecter et naviguer.
+
+### Fonctionnalités de gestion du compte
+
+1. Un visiteur anonyme doit pouvoir : (~5 points)
+	- voir la page d'accueil
+	- créer un compte
+	- se connecter
+2. Un utilisateur connecté doit pouvoir : (~6 points)
+	- changer son mot de passe (les mots de passes doivent être chiffrés)
+	- supprimer son compte
+
+> Note: Au moment de la connexion, c'est le nom de l'utilisateur qui est enregistré dans une variable de session et qui pourra (devra) être réutilisée lors de la gestion des postes.
+
+### Fonctionnalités de gestion du parc informatique
+
+Les fonctionnalités de gestion du parc informatique doivent uniquement être réalisables si l'utilisateur est connecté. Un utilisateur connecté doit pouvoir :
+
+1. Lister tous les postes informatiques avec pour chacun son id, sa salle et l'OS installé.
+
+2. Ajouter un nouveau poste informatique en indiquant :
+	- le numéro de la salle (balise `<input>` de type `number`)
+	- l'OS (balise `<select>` contenant 4 `<option>` : Ubuntu, Debian, MacOS, et Windows)
+
+3. Supprimer un poste depuis la page listant tous les postes, avec un lien spécifique pour chaque poste.
+
+4. Lister toutes les réservations avec le n° de poste concerné, l'id de l'utilisateur concerné (qui peut être présent dans les varaibles de session), les dates de début et de fin, et si l'utilisateur aura les droits d'administration.
+
+5. Réserver un poste pour soi en indiquant :
+	- l'identifiant du poste (élément `input` de type `number`)
+	- la date de début d'utilisation (élément `input` de type `date`)
+	- la date de fin d'utilisation (élément `input` de type `number`)
+	- les droits sur le poste (élément `<select>` contenant 2 `<option>` : admin ou user)
+
+6. Supprimer une réservation depuis la page listant toutes les réservations avec un lien différent pour chaque réservation
+
+7. Visualiser toutes les réservations liées à un poste donné depuis la page listant tous les postes, avec un lien spécifique ajouté au niveau de chaque poste.
+
+8. Lister toutes mes réservations.
+
+
+> *Indication* :
+> Les champs de type `date` doivent être traitée comme une chaîne de caractères au format YYYY-MM-DD lors de la construction de la requête.
+> Il se trouve que c'est dans ce format qu'un élément HTML input de type "date" formate la date lors la soumission du formulaire.

+ 124 - 0
TP-note-2018/init_db.sql

@@ -0,0 +1,124 @@
+-- phpMyAdmin SQL Dump
+-- version autre
+-- https://www.phpmyadmin.net/
+--
+-- Host: localhost
+-- Generation Time: un jour...
+-- Server version: une version...
+-- PHP Version: une autre version...
+
+SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
+SET AUTOCOMMIT = 0;
+START TRANSACTION;
+SET time_zone = "+00:00";
+
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8mb4 */;
+
+--
+-- Database: `ParcInfo`
+--
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `Postes`
+--
+
+DROP TABLE IF EXISTS `Postes`;
+CREATE TABLE `Postes` (
+  `id` int(11) NOT NULL,
+  `salle` int(3) NOT NULL,
+  `os` enum('Ubuntu','Debian','MacOS','Windows') NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
+
+--
+-- Dumping data for table `Postes`
+--
+
+INSERT INTO `Postes` (`id`, `salle`, `os`) VALUES
+(1, 5, 'Ubuntu'),
+(2, 5, 'Windows'),
+(3, 5, 'Debian'),
+(4, 5, 'MacOS'),
+(5, 17, 'Ubuntu'),
+(6, 17, 'Debian'),
+(7, 105, 'Ubuntu'),
+(8, 105, 'MacOS'),
+(9, 106, 'Ubuntu'),
+(10, 106, 'Debian');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `Reservations`
+--
+
+DROP TABLE IF EXISTS `Reservations`;
+CREATE TABLE `Reservations` (
+  `id` int(11) NOT NULL,
+  `user_id` varchar(255) NOT NULL,
+  `poste_id` int(11) NOT NULL,
+  `date_debut` date NOT NULL,
+  `date_fin` date NOT NULL,
+  `est_root` tinyint(1) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `Users`
+--
+
+DROP TABLE IF EXISTS `Users`;
+CREATE TABLE `Users` (
+  `login` varchar(255) NOT NULL,
+  `password` varchar(255) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
+
+--
+-- Indexes for dumped tables
+--
+
+--
+-- Indexes for table `Postes`
+--
+ALTER TABLE `Postes`
+  ADD PRIMARY KEY (`id`);
+
+--
+-- Indexes for table `Reservations`
+--
+ALTER TABLE `Reservations`
+  ADD PRIMARY KEY (`id`);
+
+--
+-- Indexes for table `Users`
+--
+ALTER TABLE `Users`
+  ADD PRIMARY KEY (`login`);
+
+
+ALTER TABLE `Users`
+  ADD UNIQUE(`login`);
+
+--
+-- AUTO_INCREMENT for dumped tables
+--
+
+--
+-- AUTO_INCREMENT for table `Postes`
+--
+ALTER TABLE `Postes`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
+--
+-- AUTO_INCREMENT for table `Reservations`
+--
+ALTER TABLE `Reservations`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;