From 9b25e5b785a25541496ca2b133efc2e1b8d1677d Mon Sep 17 00:00:00 2001 From: Christiaan Goossens Date: Thu, 9 Feb 2017 07:50:51 +0100 Subject: [PATCH] Skeleton --- .gitignore | 2 + README.md | 23 ++++ composer.json | 14 ++ composer.lock | 305 ++++++++++++++++++++++++++++++++++++++++++ public/.htaccess | 10 ++ public/index.php | 30 +++++ src/dependencies.php | 10 ++ src/middleware.php | 4 + src/routes.php | 7 + src/settings.php | 12 ++ templates/index.phtml | 38 ++++++ 11 files changed, 455 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 public/.htaccess create mode 100644 public/index.php create mode 100644 src/dependencies.php create mode 100644 src/middleware.php create mode 100644 src/routes.php create mode 100644 src/settings.php create mode 100644 templates/index.phtml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cd7aa82 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/vendor/ +/logs/* diff --git a/README.md b/README.md new file mode 100644 index 0000000..be30eef --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# Informatica Eindproject + +Om te kunnen werken aan dit project moet je het volgende doen: + +Je doet een git clone (in een random map) (het spreekt voor zich dat je hier eerst git (https://git-scm.com/downloads) moet installeren) met `git clone https://git.verictas.com/InformaticaD4p/informatica-eindproject.git`. Er verschijnt nu een nieuwe map genaamd `informatica-eindproject`. In deze map ga je werken. + +Om te starten heb je ook een PHP installatie nodig op je PC. Ik heb een zip bsetand met de php installatie op christiaangoossens.nl/uploads/afc06760-f1b9-4458-8d93-fc6ea8b2a828/php7.zip. Je pakt dit bestand uit en vindt dan een map genaamd `php7`. Deze map zet je neer op een logische plek (bijv. C:/php7 of C:/Program Files/php7) en die voeg je dan toe aan je windows path (dat kun je doen via Configuratischerm>System>Opstartvariabelen of met dit commando in de shell (cmd): `set PATH=%PATH%;C:\php7` (let op, wel het path veranderen naar de map waar je de `php7` map hebt neergezet). + +Als het goed is kun je in de `informatica-eindproject` map nu het volgende commando uitvoeren (mag in CMD of de Git shell): `php -v`. Je krijgt dan het volgende te zien: + +``` +PHP 7.1.1 (cli) (built: Jan 18 2017 18:50:48) ( NTS MSVC14 (Visual C++ 2015) x86 ) +Copyright (c) 1997-2017 The PHP Group +Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies +``` + +Je bent nu klaar om Composer te installeren. Composer is een hulpprogramma wat alle benodigdheden voor jouw project automatisch download en toevoegt. Je kunt de Composer installer vinden op: https://getcomposer.org/download/. + +Composer zal je tijdens de installatie vragen om je php versie op te geven, dit staat waarschijnlijk automatisch goed, maar je kunt hem ook zelf zoeken. + +Zodra alles geinstalleerd is, ga je terug naar de `informatica-eindproject` map en doe je een `composer install` in de commandline. Alle benodigdheden worden nu gedownload en geinstalleerd. + +Je kunt je website nu starten via `composer start`. Er zal dan een webserver voor je worden gestart. Je kunt nu zelf een webbrowser openen om naar `http://localhost:8080` te gaan, en dan zul je je website zien. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..d508ce8 --- /dev/null +++ b/composer.json @@ -0,0 +1,14 @@ +{ + "require": { + "php": ">=5.5.0", + "slim/slim": "^3.1", + "slim/php-view": "^2.0" + }, + "config": { + "process-timeout" : 0 + }, + "scripts": { + "start": "php -S 0.0.0.0:8080 -t public public/index.php" + } + +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..4d8df69 --- /dev/null +++ b/composer.lock @@ -0,0 +1,305 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "37fe8b36d00a40955cbd52e4949aa8f1", + "packages": [ + { + "name": "container-interop/container-interop", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/container-interop/container-interop.git", + "reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/container-interop/container-interop/zipball/fc08354828f8fd3245f77a66b9e23a6bca48297e", + "reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Interop\\Container\\": "src/Interop/Container/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", + "time": "2014-12-30T15:22:37+00:00" + }, + { + "name": "nikic/fast-route", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/nikic/FastRoute.git", + "reference": "b5f95749071c82a8e0f58586987627054400cdf6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/FastRoute/zipball/b5f95749071c82a8e0f58586987627054400cdf6", + "reference": "b5f95749071c82a8e0f58586987627054400cdf6", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "FastRoute\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov", + "email": "nikic@php.net" + } + ], + "description": "Fast request router for PHP", + "keywords": [ + "router", + "routing" + ], + "time": "2017-01-19T11:35:12+00:00" + }, + { + "name": "pimple/pimple", + "version": "v3.0.2", + "source": { + "type": "git", + "url": "https://github.com/silexphp/Pimple.git", + "reference": "a30f7d6e57565a2e1a316e1baf2a483f788b258a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/silexphp/Pimple/zipball/a30f7d6e57565a2e1a316e1baf2a483f788b258a", + "reference": "a30f7d6e57565a2e1a316e1baf2a483f788b258a", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Pimple": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Pimple, a simple Dependency Injection Container", + "homepage": "http://pimple.sensiolabs.org", + "keywords": [ + "container", + "dependency injection" + ], + "time": "2015-09-11T15:10:35+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06T14:39:51+00:00" + }, + { + "name": "slim/php-view", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/slimphp/PHP-View.git", + "reference": "122ed121a8d9cf91a94020814d2a3ee6c836754f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slimphp/PHP-View/zipball/122ed121a8d9cf91a94020814d2a3ee6c836754f", + "reference": "122ed121a8d9cf91a94020814d2a3ee6c836754f", + "shasum": "" + }, + "require": { + "psr/http-message": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8", + "slim/slim": "^3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Slim\\Views\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Glenn Eggleton", + "email": "geggleto@gmail.com" + } + ], + "description": "Render PHP view scripts into a PSR-7 Response object.", + "keywords": [ + "framework", + "php", + "phtml", + "renderer", + "slim", + "template", + "view" + ], + "time": "2016-10-11T07:43:08+00:00" + }, + { + "name": "slim/slim", + "version": "3.7.0", + "source": { + "type": "git", + "url": "https://github.com/slimphp/Slim.git", + "reference": "4254e40d81559e35cdf856bcbaca5f3af468b7ef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slimphp/Slim/zipball/4254e40d81559e35cdf856bcbaca5f3af468b7ef", + "reference": "4254e40d81559e35cdf856bcbaca5f3af468b7ef", + "shasum": "" + }, + "require": { + "container-interop/container-interop": "^1.1", + "nikic/fast-route": "^1.0", + "php": ">=5.5.0", + "pimple/pimple": "^3.0", + "psr/http-message": "^1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0", + "squizlabs/php_codesniffer": "^2.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Slim\\": "Slim" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Rob Allen", + "email": "rob@akrabat.com", + "homepage": "http://akrabat.com" + }, + { + "name": "Josh Lockhart", + "email": "hello@joshlockhart.com", + "homepage": "https://joshlockhart.com" + }, + { + "name": "Gabriel Manricks", + "email": "gmanricks@me.com", + "homepage": "http://gabrielmanricks.com" + }, + { + "name": "Andrew Smith", + "email": "a.smith@silentworks.co.uk", + "homepage": "http://silentworks.co.uk" + } + ], + "description": "Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs", + "homepage": "https://slimframework.com", + "keywords": [ + "api", + "framework", + "micro", + "router" + ], + "time": "2016-12-20T20:30:47+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.5.0" + }, + "platform-dev": [] +} diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..c506092 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,10 @@ +RewriteEngine On + +# Some hosts may require you to use the `RewriteBase` directive. +# If you need to use the `RewriteBase` directive, it should be the +# absolute physical path to the directory that contains this htaccess file. +# +# RewriteBase / + +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^ index.php [QSA,L] diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..2784ee0 --- /dev/null +++ b/public/index.php @@ -0,0 +1,30 @@ +run(); diff --git a/src/dependencies.php b/src/dependencies.php new file mode 100644 index 0000000..af58864 --- /dev/null +++ b/src/dependencies.php @@ -0,0 +1,10 @@ +getContainer(); + +// view renderer +$container['renderer'] = function ($c) { + $settings = $c->get('settings')['renderer']; + return new Slim\Views\PhpRenderer($settings['template_path']); +}; diff --git a/src/middleware.php b/src/middleware.php new file mode 100644 index 0000000..116a0ff --- /dev/null +++ b/src/middleware.php @@ -0,0 +1,4 @@ +add(new \Slim\Csrf\Guard); diff --git a/src/routes.php b/src/routes.php new file mode 100644 index 0000000..ea11a20 --- /dev/null +++ b/src/routes.php @@ -0,0 +1,7 @@ +get('/[{name}]', function ($request, $response, $args) { + // Render index view + return $this->renderer->render($response, 'index.phtml', $args); +}); diff --git a/src/settings.php b/src/settings.php new file mode 100644 index 0000000..fe7e7b2 --- /dev/null +++ b/src/settings.php @@ -0,0 +1,12 @@ + [ + 'displayErrorDetails' => true, // set to false in production + 'addContentLengthHeader' => false, // Allow the web server to send the content-length header + + // Renderer settings + 'renderer' => [ + 'template_path' => __DIR__ . '/../templates/', + ] + ], +]; diff --git a/templates/index.phtml b/templates/index.phtml new file mode 100644 index 0000000..d732287 --- /dev/null +++ b/templates/index.phtml @@ -0,0 +1,38 @@ + + + + + Slim 3 + + + + +

Slim

+
a microframework for PHP
+ + +

Hello !

+ +

Try SlimFramework + + +