Dateien hochladen nach „“

This commit is contained in:
Tobias Hopp 2020-06-24 22:15:28 +02:00
parent afd29103e4
commit 7303c06335
5 changed files with 167 additions and 2 deletions

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Tobias Hopp
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,3 +1,74 @@
# model-view-controller-php
# Model View Controller principle for PHP
This MVC is a **M**odel **V**iew **C**ontroller "principle" for PHP 7.
It forms PHP to an object-oriented programming language.
## Getting Started
Download the latest version of our project under releases and extract the ZIP file into your project folder.
Have a look around first.
The following files/folders are important:
- config.inc.php
- index.php
* controller/
* model/
* templates/
* views/
Under views/ you can find the current default template loader.
It replaces the following string in an HTML document: "[[KEY]]".
Templates can be found in the templates/ folder.
For example, if you don't want to use HTML as output, you can create your own view or edit the existing one instead.
Under controller/ is the main part.
There all models are addressed and actions are executed.
As a little thought support, there should already be a sample controller under controller/.
The model/ folder is used to execute certain actions, e.g. a MySQL query. It does not "think" itself.
The index file actually does the least.
It should be edited as once as possible and then everything should only be done with controllers and models.
The config.inc.php is used for the central storage of e.g. user data like MySQL data. Let your imagination run wild ^^.
### Prerequisites
Please use at least a PHP version of 7.0.
Only PHP7 should be installed.
### Installing
To download the project, go to the [releases](https://git.gaminggeneration.de/Tobstr_/modelviewcontroller-php/-/releases). and download the latest ZIP file.
Now unzipping all files into your project directory.
And that's it!
Have fun with tinkering.
**PS:** Yeah, it's it's *normally* that you enjoy an error when you run it the first time without any configuration!
It's because the connection to the MySQL server fails.
## Versioning
We use normal version names like v1.0.
Just download the newest ZIP.
To find out if the version you want to download is still supported, you can view [Security.md](https://github.com/Tobstr02/modelviewcontroller-php/blob/master/SECURITY.md) here.
The following PHP versions have been tested and run without problems under the version:
- *7.0*
- 7.1
- 7.2
- 7.3
- **7.4**
## Documentation
To view some documentation about this PHP-MVC, visit the [Wiki](https://git.gaminggeneration.de/Tobstr_/modelviewcontroller-php/-/wikis/home) page of this repository.
## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
ModelViewController prinzip für PHP

18
SECURITY.md Normal file
View File

@ -0,0 +1,18 @@
# Security Policy
## Supported Versions
We are currently maintaining the following versions:
| Version | Supported |
| ------- | ------------------ |
| v1.0 | :white_check_mark: |
| v1.1 | :ballot_box_with_check: |
## Supported & Tested PHP-Versions:
- 7.0
- 7.1
- 7.2
- 7.3
PHP versions below 7.0 get errors because of unique type assignments.

26
index.php Normal file
View File

@ -0,0 +1,26 @@
<?php
/**
* Includes the main inc
* This is the index file.
*/
require_once __DIR__ . '/main.inc.php';
try
{
# Initialize Request
$request = new Request();
# Get Controller from Factory
$controller = Factory::getController( $request );
# Get Action from Factory
$action = Factory::getAction( $controller, $request );
# Call controller and action
echo $controller->$action();
}
catch ( Exception $e )
{
# Please replace it with error template
die( 'An internal error occured while processing your request.' );
}

29
main.inc.php Normal file
View File

@ -0,0 +1,29 @@
<?php
/**
* Main file load's all the important files and the autoloader.
* Bindet alles ein und setzt einige Variablen sowie die Datenbank.
*/
require_once __DIR__ . '/classes/Autoloader.class.inc.php';
require_once __DIR__ . '/config.inc.php';
# Registering autoloader
Autoloader::register();
try
{
$host = MYSQL_HOST;
$dbname = MYSQL_DB;
# Creates a mysql connection
$pdo = new PDO( "mysql:host={$host};dbname={$dbname}", MYSQL_USER, MYSQL_PASS, array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ) );
# Set DB connection
Database::setConnection( $pdo );
}
catch ( Exception $e )
{
# Error occured, please replace it with error template
die( 'An internal error occured while proccessing your request' );
}