Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add namespace for all php classess #9

Merged
merged 9 commits into from
Nov 10, 2024
7 changes: 6 additions & 1 deletion app/controllers/Auth.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php

require_once __DIR__ . "/../core/Controller.php";
namespace App\Controllers;

require_once __DIR__ . '/../core/Controller.php';

use App\Core\Controller;


class Auth extends Controller {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php

require_once __DIR__ . "/../core/Controller.php";
namespace App\Controllers;

class HomeController extends Controller {
require_once __DIR__ . '/../core/Controller.php';

use App\Core\Controller;

class Home extends Controller {

public function __construct() {
$this->model = null;
Expand Down
13 changes: 13 additions & 0 deletions app/controllers/Students.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Controllers;

require_once __DIR__ . '/../core/Controller.php';
require_once __DIR__ . '/../models/Student.php';

use App\Core\Controller;


class Students extends Controller {

}
8 changes: 0 additions & 8 deletions app/controllers/StudentsController.php

This file was deleted.

2 changes: 2 additions & 0 deletions app/core/Controller.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace App\Core;

class Controller {
public ?Model $model;

Expand Down
5 changes: 5 additions & 0 deletions app/core/Database.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?php

namespace App\Core;

use PDO;
use PDOException;

class Database {
private string $DB_SERVER = "";
private string $DB_NAME = "";
Expand Down
6 changes: 6 additions & 0 deletions app/core/Model.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?php

namespace App\Core;

use PDO;
use PDOException;
use PDOStatement;

class Model {
private Database $db;

Expand Down
8 changes: 5 additions & 3 deletions app/core/Router.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

require_once __DIR__ ."/Database.php";
require_once __DIR__ ."/Controller.php";
require_once __DIR__ ."/Model.php";
namespace App\Core;

require_once __DIR__ . '/Database.php';
require_once __DIR__ . '/Controller.php';
require_once __DIR__ . '/Model.php';

class Router {

Expand Down
8 changes: 0 additions & 8 deletions app/models/Student.php

This file was deleted.

12 changes: 12 additions & 0 deletions app/models/Students.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Models;

require_once __DIR__ . '/../core/Model.php';

use App\Core\Model;


class Students extends Model {

}
10 changes: 7 additions & 3 deletions public/index.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<?php

require_once __DIR__ . '/../app/core/Router.php';
require_once __DIR__ . '/../app/controllers/HomeController.php';
require_once __DIR__ . '/../app/controllers/Home.php';
require_once __DIR__ . '/../app/controllers/Auth.php';

Router::add('GET', '/', HomeController::class, 'index');
Router::add('GET', '/kontak', HomeController::class,'contact');
use App\Core\Router;
use App\Controllers\{Home, Auth};


Router::add('GET', '/', Home::class, 'index');
Router::add('GET', '/kontak', Home::class,'contact');
Router::add('GET','/login', Auth::class,'login');

Router::run();