Simple php framework using MVC pattern.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
What things you need to have installed on your local machine.
PHP v.7
Access to MySQL database as super user
A step by step series of examples that tell you how to get a development env running
-
Move all the files to your www root dir
-
Import database structure from DB.sql
mysql db_name < DB.sql
- Run web server and open the browser
-
App
-
Controller
-
Cookie
-
Checking if cookie is set
Cookie::exists("name")
If is set Cookie with the name we provide, returns true, otherwise false.
-
Get the cookie value
Cookie::get("name")
Returns Cookie value.
-
Set a cookie
Cookie::put("name", "value", ["expiry"])
Sets a cookie with name and value we provide, returns boolean. Expiry date by default is set in config file.
-
Delete a cookie
Cookie::delete("name")
Delets a cookie with the name we provide.
-
-
Database
-
Creating connection
Database::instance();
-
Selecting data
Database::instance()->query('SELECT * FROM table WHERE field= :field', ['field' => Value1]);
-
See results
(...)->results();
Returns array of data.
-
See first result
(...)->first();
Returns first element of an result array. If first element does not exists, returns undefined.
-
-
Inserting data
Database::instance()->query('INSERT INTO table VALUES (:field1, :field2)', ['field1' => Value1', 'field2' => Value2']);
-
Error check
(...)->error();
Returns boolean.
-
-
-
File
-
Hash
-
String hashing
Hash::make('string');
Returns hashed string.
-
Verify hashed string
Hash::check("string", "hash");
Returns boolean if string matches hashed string;
-
Generate random string
Hash:unique(length)
Returns unique string with a specified length.
-
-
Input
-
Getting value from input
Input::get('fieldName')
If is set, returns sanitized input value from GET, or POST array. Otherwise, returns empty string.
-
-
Model
-
Redirect
Redirect::to(location);
Accepts numeric values, as error types. If URL, redirect to URL.
-
Request
-
Request check
Request::method('string', callback);
Default value 'GET', runs callback.
-
-
Session
-
Checking if session is set
Session::exists("name");
If is set Session with the name we provide, returns true, otherwise false.
-
Get the session value
Session::get("name");
Returns session value.
-
Set a session
Session::put("name", "value");
Sets a session with name and value we provide, returns session value.
-
Delete a session
Session::delete("name");
Unsets a session with the name we provide.
-
Flash a session
Session::flash("name", ["string" = null]);
If session exists, returns it's value, then unsets session. If no session, it puts a session with the name and value.
-
-
Validation
- PHP
- MySQL
- Jakub Skoneczny - Initial work - Profile