All Projects → mmilanovic4 → mvc

mmilanovic4 / mvc

Licence: GPL-3.0 license
PHP MVC boilerplate with user authentication, basic security and MySQL CRUD operations.

Programming Languages

PHP
23972 projects - #3 most used programming language
TSQL
950 projects
CSS
56736 projects

Projects that are alternatives of or similar to mvc

Desenvolvimento-Android-do-absoluto-zero-para-iniciantes
Visite meu site e conheça todos os meus cursos 100% on-line.
Stars: ✭ 33 (+17.86%)
Mutual labels:  crud, mvc
Silexstarter
Starter app based on Silex framework with mvc and modular arch, scaffold generator, and admin panel
Stars: ✭ 11 (-60.71%)
Mutual labels:  crud, mvc
servant-beam-realworld-example-app
Exemplary fullstack Medium.com clone powered by Servant and Beam
Stars: ✭ 33 (+17.86%)
Mutual labels:  crud, web-application
Blueprint
Blueprint for your next web application in Go.
Stars: ✭ 446 (+1492.86%)
Mutual labels:  mvc, web-application
.NET-Core-Learning-Journey
Some of the projects i made when starting to learn .NET Core
Stars: ✭ 37 (+32.14%)
Mutual labels:  crud, mvc
Butterfly
🔥 蝴蝶--【简单】【稳定】【好用】的 Python web 框架🦋 除 Python 2.7,无其他依赖; 🦋 butterfly 是一个 RPC 风格 web 框架,同时也是微服务框架,自带消息队列通信机制实现分布式
Stars: ✭ 82 (+192.86%)
Mutual labels:  mvc, web-application
Jsonapidotnetcore
JSON:API Framework for ASP.NET Core
Stars: ✭ 465 (+1560.71%)
Mutual labels:  crud, mvc
ASP.NET-Core-2-MVC-CRUD-datatables-jQuery-Plugin
Asp.Net Example implementation of datatables.net using Asp.Net Core 2 Mvc CRUD datatables jQuery Plugin
Stars: ✭ 25 (-10.71%)
Mutual labels:  crud, mvc
softn-cms
Sistema de gestión de contenidos
Stars: ✭ 22 (-21.43%)
Mutual labels:  mvc, oop
velox
The minimal PHP micro-framework.
Stars: ✭ 55 (+96.43%)
Mutual labels:  crud, mvc
Laconia
🏺 ‎ A minimalist MVC framework.
Stars: ✭ 307 (+996.43%)
Mutual labels:  mvc, oop
spe
A series of PHP8 examples based around a super simple MVC framework (WIP)
Stars: ✭ 14 (-50%)
Mutual labels:  mvc, oop
Pmanager
A project management system built using laravel. Watch full video here
Stars: ✭ 260 (+828.57%)
Mutual labels:  mvc, oop
Interviews
A list of fancy questions I've been asked during the interviews I had. Some of them I ask when interviewing people.
Stars: ✭ 140 (+400%)
Mutual labels:  mvc, oop
php-mvc-skeleton
A PHP OOP web application skeleton that uses MVC architectural pattern to create a basic application that contains login and multi language systems and can be used in any web project.
Stars: ✭ 46 (+64.29%)
Mutual labels:  mvc, oop
trac-nghiem-online
Xây dựng hệ thống trắc nghiệm online cho các trường THCS, THPT một cách nhanh chóng và dễ dàng. Không cần phải là lập trình viên
Stars: ✭ 64 (+128.57%)
Mutual labels:  mvc, oop
estore
Electronic Store Application - A web based application developed using PHP and Driven by MySQL Database
Stars: ✭ 48 (+71.43%)
Mutual labels:  mvc, oop
django-views-tutorial
🚀 ✅ Function and class-based Django view repository.
Stars: ✭ 19 (-32.14%)
Mutual labels:  mvc
databrary
behavioral science research media data sharing web application
Stars: ✭ 49 (+75%)
Mutual labels:  web-application
login-server
Login and connect accounts with multiple identity providers
Stars: ✭ 28 (+0%)
Mutual labels:  web-application

PHP MVC Boilerplate

Overview

PHP MVC boilerplate with user authentication, basic security and MySQL CRUD operations. Framework was developed during the final year of university. It was used for some private projects, however I highly suggest you to use Laravel or some other popular framework for your work.

Requirements

  • Web server: Apache with mod_rewrite enabled
  • Database server: MySQL
  • PHP 7.x

Optional

  • ApiGen / phpDocumentor
  • PHPUnit

Login operation

If you imported database data from sys/db/dump.sql, you could authenticate with following credentials:

If you're manually adding user to users table, don't forget to append salt from sys/Config.php before hashing with SHA-512 algorithm.

Login form

CRUD operations

Each database table should have appropriate model file. For example, table tasks have app/models/TaskModel.php. There you need to hardcode table name in protected $tableName property and eventually add new functions. Provided functions with basic model are:

  • read
  • readAll
  • create
  • update
  • delete

CRUD operations

Router

All routes should be placed inside routes.php. Each route must have following properties:

  • Name of the controller whom the route belongs to
  • Name of the controller's method (the route callback)
  • Request URI, represented via PCRE

For example, if we have following code:

...
new Route('Home', 'index', '|^/?$|'),
...

it means that when user visits URI which matched RegEx |^/?$|, index.php will instantiate HomeController.php and call his index method.

RegEx cheat sheet

Route Regex
/ |^/?$|
users/ |^users/?$|
users/create/ |^users/create/?$|
users/update/15/ |^users/update/([0-9]+)/?$|
users/delete/4/ |^users/delete/([0-9]+)/?$|
store/iphone-8-64gb/ |^store/([a-z0-9]+(?:\-[a-z0-9]+)*)/?$|
Anything |^.*$|

Security

Framework provides basic security mechanisms.

SQL injection

Model class uses prepared statements and Database class uses PDO's DSN charset parameter to set connection encoding to utf8. It is impossible for an attacker to inject malicious SQL this way. For providing defense in depth, you can use input validation - for applications that demand higher level of security, I use input validation not only in PHP, but in MySQL also (via triggers).

XSS

For basic XSS protection (e.g. when we need to insert data in HTML body) you can use Security class. For example, if we need to insert $DATA['user'] in our HTML, we would use following code:

...
<p><?= Security::escape($DATA['user']); ?></p>
...

However, that wouldn't protect us if we needed to insert data inside <script> tag, for example. Visit OWASP page for further instructions. If you want to use third-party library for defense in depth, HTML Purifier is a good one. For API responses in JavaScript, don't forget to use safe JavaScript functions and properties (e.g. element.textContent, jQuery .text() function etc.) when you need to populate the DOM.

Data exposure

This framework provides user authentication functionallity, however if you intend to use it, in order for your users to be protected, you need to use HTTPS (HTTP + SSL). Without SSL encryption anyone could intercept the transmission from your browser to the server. Today, this is completely free thanks to initiatives like Let's Encrypt CA. I highly advise that you use HTTPS-related mechanisms like HSTS and HPKP as well.

Documentation

Great tool for generating documentation is ApiGen. You can install it via Composer (I prefer doing it globally) and simply run:

apigen generate --source MVC --destination MVC/docs
firefox docs/index.html &

Due to the recent problems with ApiGen and PHP 7.2, I used phpDocumentor as an alternative. Install phpDocumentor and run:

phpdoc --directory MVC --target MVC/docs
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].