diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..34584c0 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md index 688a087..e8406d0 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..805003c --- /dev/null +++ b/SECURITY.md @@ -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. diff --git a/index.php b/index.php new file mode 100644 index 0000000..5b9c7e4 --- /dev/null +++ b/index.php @@ -0,0 +1,26 @@ +$action(); + +} +catch ( Exception $e ) +{ + # Please replace it with error template + die( 'An internal error occured while processing your request.' ); +} diff --git a/main.inc.php b/main.inc.php new file mode 100644 index 0000000..a4fb7a7 --- /dev/null +++ b/main.inc.php @@ -0,0 +1,29 @@ + 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' ); +}