diff --git a/README.md b/README.md
deleted file mode 100644
index 3c025b9..0000000
--- a/README.md
+++ /dev/null
@@ -1,34 +0,0 @@
-# PHP MVC framework
-Minimalistic custom framework created for educational purposes.
-
-
-
-## The framework is not well tested on production. If you use it on production you use it on your own risk.
-**Related core package**: https://github.com/thecodeholic/tc-php-mvc-core
-
-----
-## Installation
-
-1. Download the archive or clone the project using git
-2. Create database schema
-3. Create `.env` file from `.env.example` file and adjust database parameters (including schema name)
-4. Run `composer install`
-5. Run migrations by executing `php migrations.php` from the project root directory
-6. Go to the `public` folder
-7. Start php server by running command `php -S 127.0.0.1:8080`
-8. Open in browser http://127.0.0.1:8080
-
-------
-## Installation using docker
-Make sure you have docker installed. To see how you can install docker on Windows [click here](https://youtu.be/2ezNqqaSjq8).
-Make sure `docker` and `docker-compose` commands are available in command line.
-
-1. Clone the project using git
-1. Copy `.env.example` into `.env` (Don't need to change anything for local development)
-1. Navigate to the project root directory and run `docker-compose up -d`
-1. Install dependencies - `docker-compose exec app composer install`
-1. Run migrations - `docker-compose exec app php migrations.php`
-8. Open in browser http://127.0.0.1:8080
-
-> The project was created along with Youtube Video Series "[Build PHP MVC Framework](https://www.youtube.com/playlist?list=PLLQuc_7jk__Uk_QnJMPndbdKECcTEwTA1)".
-> I appreaciate if you share it.
diff --git a/controllers/AboutController.php b/controllers/AboutController.php
index b746311..a1fca6c 100644
--- a/controllers/AboutController.php
+++ b/controllers/AboutController.php
@@ -1,9 +1,4 @@
* @package app\controllers
*/
class AboutController extends Controller
diff --git a/controllers/SiteController.php b/controllers/SiteController.php
index fdb79b4..b35a849 100644
--- a/controllers/SiteController.php
+++ b/controllers/SiteController.php
@@ -1,9 +1,4 @@
* @package app\controllers
*/
class SiteController extends Controller
@@ -29,18 +23,10 @@ public function __construct()
$this->registerMiddleware(new AuthMiddleware(['profile']));
}
- public function home()
- {
- return $this->render('home', [
- 'name' => 'TheCodeholic'
- ]);
- }
public function login(Request $request)
{
- echo '
';
- var_dump($request->getBody(), $request->getRouteParam('id'));
- echo '';
+
$loginForm = new LoginForm();
if ($request->getMethod() === 'post') {
$loginForm->loadData($request->getBody());
@@ -55,44 +41,10 @@ public function login(Request $request)
]);
}
- public function register(Request $request)
- {
- $registerModel = new User();
- if ($request->getMethod() === 'post') {
- $registerModel->loadData($request->getBody());
- if ($registerModel->validate() && $registerModel->save()) {
- Application::$app->session->setFlash('success', 'Thanks for registering');
- Application::$app->response->redirect('/');
- return 'Show success page';
- }
-
- }
- $this->setLayout('auth');
- return $this->render('register', [
- 'model' => $registerModel
- ]);
- }
-
public function logout(Request $request, Response $response)
{
Application::$app->logout();
$response->redirect('/');
}
- public function contact()
- {
- return $this->render('contact');
- }
-
- public function profile()
- {
- return $this->render('profile');
- }
-
- public function profileWithId(Request $request)
- {
- echo ''; - var_dump($request->getBody()); - echo ''; - } } diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 8f1a64c..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,29 +0,0 @@ -version: "3.7" - -services: - app: - build: ./docker - image: thecodeholic/php_mvc - ports: - - "8080:80" - volumes: - # Mount source-code for development - - ./:/var/www - extra_hosts: - - host.docker.internal:host-gateway - - db: - image: mysql:8 - ports: - - "3307:3306" - volumes: - - mysql-data:/var/lib/mysql - - ./docker/mysql-config.cnf:/etc/mysql/conf.d/config.cnf - environment: - MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: php_mvc - MYSQL_USER: php_mvc - MYSQL_PASSWORD: php_mvc - -volumes: - mysql-data: \ No newline at end of file diff --git a/migrations.php b/migrations.php index ab7cf2f..e45d0cb 100644 --- a/migrations.php +++ b/migrations.php @@ -1,9 +1,4 @@ * @package app\models */ class LoginForm extends Model diff --git a/models/User.php b/models/User.php index 2cc6383..d0376ce 100644 --- a/models/User.php +++ b/models/User.php @@ -1,9 +1,4 @@ * @package app\models */ class User extends UserModel diff --git a/public/index.php b/public/index.php index 8572ddf..5fcd761 100644 --- a/public/index.php +++ b/public/index.php @@ -1,9 +1,4 @@ load(); $config = [ @@ -19,26 +15,26 @@ 'dsn' => $_ENV['DB_DSN'], 'user' => $_ENV['DB_USER'], 'password' => $_ENV['DB_PASSWORD'], - ] + ], + ]; $app = new Application(dirname(__DIR__), $config); -$app->on(Application::EVENT_BEFORE_REQUEST, function(){ +$app->on(Application::EVENT_BEFORE_REQUEST, function () { // echo "Before request from second installation"; }); +$app->router->get('/', function () { + header('Location: /login'); +}); -$app->router->get('/', [SiteController::class, 'home']); -$app->router->get('/register', [SiteController::class, 'register']); -$app->router->post('/register', [SiteController::class, 'register']); $app->router->get('/login', [SiteController::class, 'login']); +$app->router->get('/login', [SiteController::class, 'login']); +$app->router->get('/admin', [SiteController::class, 'ad']); $app->router->get('/login/{id}', [SiteController::class, 'login']); $app->router->post('/login', [SiteController::class, 'login']); $app->router->get('/logout', [SiteController::class, 'logout']); -$app->router->get('/contact', [SiteController::class, 'contact']); -$app->router->get('/about', [AboutController::class, 'index']); -$app->router->get('/profile', [SiteController::class, 'profile']); -$app->router->get('/profile/{id:\d+}/{username}', [SiteController::class, 'login']); +//var_dump(Application::$app->user); // /profile/{id} // /profile/13 // \/profile\/\w+ diff --git a/views/_error.php b/views/_error.php index 1999856..67c0857 100644 --- a/views/_error.php +++ b/views/_error.php @@ -1,8 +1,5 @@ diff --git a/views/about.php b/views/about.php deleted file mode 100644 index 35f8d8b..0000000 --- a/views/about.php +++ /dev/null @@ -1 +0,0 @@ -