Skip to main content
added 484 characters in body
Source Link
Kid Diamond
  • 2.6k
  • 16
  • 35

There are only a couple of things I'd like to say:

Is this a good site structure? Do you have any tips/suggestions?

  • You might wanna create a new folder public / public_html to store all the application's public files for the web (javascripts, stylesheets, images, front-end controller, etc). Then you can set this folder as your web root so that the rest of your application code remains private. It also has the benefit of when the PHP module fails to load, only your front-end controller's code will be exposed. The rest will remain hidden.

  • I don't see a reason why you wouldn't merge config.php with index.php. They essentially do the same thing; bootstrapping the "framework".

  • May I suggest you to make use of a namespace based auto loader (e.g. the PSR-0 autoloader).

With this you don't have to keep adding new folders to your auto loader (referring to the long chain of else ifs in your current auto loader). Instead, you declare them via namespaces in your classes which makes it more efficient and handy. Additionally it prevents conflict between duplicate class names from different namespaces.

Notes

  • Your controllers are tightly coupled to their dependencies. I suggest you make use of Dependency Injection to couple them loosely. It also makes for easier testing.
  • Your Registry class introduces global state which goes against the principles of OOP and is considered an anti-pattern.

HTML code in the index.php bootstrap file is a big no no.

<a href="index.php?route=login">Login</a> <a href="index.php?route=register">Register</a>

Same goes for:

if($authService->login('[email protected]', 'testPass')) {
    $notice = 'Test logged In'; //<---
} else {
    $notice = 'Not logged in'; //<---
}

In the MVC pattern all View related logic goes in it's corresponding View class and HTML in the template.


In the show() method of your View class you're doing:

foreach ($this->vars as $key => $value) {
    $$key = $value;
}

Fortunately, extract() gets the job done with less code: extract($this->vars);.

---

Am I doing it right (according to the MVC model)?

The MVC pattern is all about separation of concerns. You've almost got that right. Make sure every type of logic resides in the appropriate layer, and you will be doing it right.

As far as the rest of your code (the "framework"), that's just detail that has nothing to do with the MVC pattern directly. The only thing it serves is to bootstrap itself so that you can utilize the MVC pattern in an easy, efficient manner.

There are only a couple of things I'd like to say:

  • You might wanna create a new folder public / public_html to store all the application's public files for the web (javascripts, stylesheets, images, front-end controller, etc). Then you can set this folder as your web root so that the rest of your application code remains private. It also has the benefit of when the PHP module fails to load, only your front-end controller's code will be exposed. The rest will remain hidden.

  • I don't see a reason why you wouldn't merge config.php with index.php. They essentially do the same thing; bootstrapping the "framework".

  • May I suggest you to make use of a namespace based auto loader (e.g. the PSR-0 autoloader).

With this you don't have to keep adding new folders to your auto loader (referring to the long chain of else ifs in your current auto loader). Instead, you declare them via namespaces in your classes which makes it more efficient and handy. Additionally it prevents conflict between duplicate class names from different namespaces.

  • Your controllers are tightly coupled to their dependencies. I suggest you make use of Dependency Injection to couple them loosely. It also makes for easier testing.
  • Your Registry class introduces global state which goes against the principles of OOP and is considered an anti-pattern.

HTML code in the index.php bootstrap file is a big no no.

<a href="index.php?route=login">Login</a> <a href="index.php?route=register">Register</a>

Same goes for:

if($authService->login('[email protected]', 'testPass')) {
    $notice = 'Test logged In'; //<---
} else {
    $notice = 'Not logged in'; //<---
}

In the MVC pattern all View related logic goes in it's corresponding View class and HTML in the template.


In the show() method of your View class you're doing:

foreach ($this->vars as $key => $value) {
    $$key = $value;
}

Fortunately, extract() gets the job done with less code: extract($this->vars);.

Is this a good site structure? Do you have any tips/suggestions?

  • You might wanna create a new folder public / public_html to store all the application's public files for the web (javascripts, stylesheets, images, front-end controller, etc). Then you can set this folder as your web root so that the rest of your application code remains private. It also has the benefit of when the PHP module fails to load, only your front-end controller's code will be exposed. The rest will remain hidden.

  • I don't see a reason why you wouldn't merge config.php with index.php. They essentially do the same thing; bootstrapping the "framework".

  • May I suggest you to make use of a namespace based auto loader (e.g. the PSR-0 autoloader).

With this you don't have to keep adding new folders to your auto loader (referring to the long chain of else ifs in your current auto loader). Instead, you declare them via namespaces in your classes which makes it more efficient and handy. Additionally it prevents conflict between duplicate class names from different namespaces.

Notes

  • Your controllers are tightly coupled to their dependencies. I suggest you make use of Dependency Injection to couple them loosely. It also makes for easier testing.
  • Your Registry class introduces global state which goes against the principles of OOP and is considered an anti-pattern.

HTML code in the index.php bootstrap file is a big no no.

<a href="index.php?route=login">Login</a> <a href="index.php?route=register">Register</a>

Same goes for:

if($authService->login('[email protected]', 'testPass')) {
    $notice = 'Test logged In'; //<---
} else {
    $notice = 'Not logged in'; //<---
}

In the MVC pattern all View related logic goes in it's corresponding View class and HTML in the template.


In the show() method of your View class you're doing:

foreach ($this->vars as $key => $value) {
    $$key = $value;
}

Fortunately, extract() gets the job done with less code: extract($this->vars);.

---

Am I doing it right (according to the MVC model)?

The MVC pattern is all about separation of concerns. You've almost got that right. Make sure every type of logic resides in the appropriate layer, and you will be doing it right.

As far as the rest of your code (the "framework"), that's just detail that has nothing to do with the MVC pattern directly. The only thing it serves is to bootstrap itself so that you can utilize the MVC pattern in an easy, efficient manner.

edited body
Source Link
Kid Diamond
  • 2.6k
  • 16
  • 35

There are only a couple of things I'd like to say:

  • You might wanna create a new folder public / public_html to store all the application's public files for the web (javascripts, stylesheets, images, front-end controller, etc). Then you can set this folder as your web root so that the rest of your application code remains private. It also has the benefit of when the PHP module fails to load, only your front-end controller's code will be exposed. The rest will remain hidden.

  • I highlydon't see a reason why you wouldn't merge config.php with index.php. They essentially do the same thing; bootstrapping the "framework".

  • May I suggest you to make use of a namespace based auto loader (e.g. the PSR-0 autoloader).

With this you don't have to keep adding new folders to your auto loader (referring to the long chain of else ifs in your current auto loader). Instead, you declare them via namespaces in your classes which makes it more efficient and handy. Additionally it prevents conflict between duplicate class names from different namespaces.

  • I don't see no reason why you wouldn't merge config.php with index.php. They essentially do the same thing; bootstrapping the "framework".

  • Your controllers are tightly coupled to their dependencies. I suggest you make use of Dependency Injection to couple them loosely. It also makes for easier testing.

    Your controllers are tightly coupled to their dependencies. I suggest you make use of Dependency Injection to couple them loosely. It also makes for easier testing.
  • TheYour Registry class introduces global state which goes against the principles of OOP and is considered an anti-pattern.

HTML code in the index.php bootstrap file is a big no no.

<a href="index.php?route=login">Login</a> <a href="index.php?route=register">Register</a>

Same goes for:

if($authService->login('[email protected]', 'testPass')) {
    $notice = 'Test logged In'; //<---
} else {
    $notice = 'Not logged in'; //<---
}

In the MVC pattern all View related logic goes in it's corresponding View class and HTML in the template.


In the show() method of your View class you're doing:

foreach ($this->vars as $key => $value) {
    $$key = $value;
}

Fortunately, extract() gets the job done with less code: extract($this->vars); gets the job done with less code. :)

There are only a couple of things I'd like to say:

  • You might wanna create a new folder public / public_html to store all the application's public files for the web (javascripts, stylesheets, images, front-end controller, etc). Then you can set this folder as your web root so that the rest of your application code remains private. It also has the benefit of when the PHP module fails to load, only your front-end controller's code will be exposed. The rest will remain hidden.

  • I highly suggest you to make use of a namespace based auto loader (e.g. the PSR-0 autoloader).

With this you don't have to keep adding new folders to your auto loader (referring to the long chain of else ifs in your current auto loader). Instead, you declare them via namespaces in your classes which makes it more efficient and handy. Additionally it prevents conflict between duplicate class names from different namespaces.

  • I don't see no reason why you wouldn't merge config.php with index.php. They essentially do the same thing; bootstrapping the "framework".

  • Your controllers are tightly coupled to their dependencies. I suggest you make use of Dependency Injection to couple them loosely. It also makes for easier testing.

  • The Registry class introduces global state which goes against the principles of OOP and is considered an anti-pattern.

HTML code in the index.php bootstrap file is a big no no.

<a href="index.php?route=login">Login</a> <a href="index.php?route=register">Register</a>

In the MVC pattern all View related logic goes in it's corresponding View class and HTML in the template.


In the show() method of your View class you're doing:

foreach ($this->vars as $key => $value) {
    $$key = $value;
}

Fortunately extract($this->vars); gets the job done with less code. :)

There are only a couple of things I'd like to say:

  • You might wanna create a new folder public / public_html to store all the application's public files for the web (javascripts, stylesheets, images, front-end controller, etc). Then you can set this folder as your web root so that the rest of your application code remains private. It also has the benefit of when the PHP module fails to load, only your front-end controller's code will be exposed. The rest will remain hidden.

  • I don't see a reason why you wouldn't merge config.php with index.php. They essentially do the same thing; bootstrapping the "framework".

  • May I suggest you to make use of a namespace based auto loader (e.g. the PSR-0 autoloader).

With this you don't have to keep adding new folders to your auto loader (referring to the long chain of else ifs in your current auto loader). Instead, you declare them via namespaces in your classes which makes it more efficient and handy. Additionally it prevents conflict between duplicate class names from different namespaces.

  • Your controllers are tightly coupled to their dependencies. I suggest you make use of Dependency Injection to couple them loosely. It also makes for easier testing.
  • Your Registry class introduces global state which goes against the principles of OOP and is considered an anti-pattern.

HTML code in the index.php bootstrap file is a big no no.

<a href="index.php?route=login">Login</a> <a href="index.php?route=register">Register</a>

Same goes for:

if($authService->login('[email protected]', 'testPass')) {
    $notice = 'Test logged In'; //<---
} else {
    $notice = 'Not logged in'; //<---
}

In the MVC pattern all View related logic goes in it's corresponding View class and HTML in the template.


In the show() method of your View class you're doing:

foreach ($this->vars as $key => $value) {
    $$key = $value;
}

Fortunately, extract() gets the job done with less code: extract($this->vars);.

edited body
Source Link
Kid Diamond
  • 2.6k
  • 16
  • 35

There are only a couple of things I'd like to say:

  • You might wanna create a new folder public / public_html to store all the application's public files for the web (javascripts, stylesheets, images, front-end controller, etc). Then you can set this folder as your web root so that the rest of your application code remains private. It also has the benefit of when the PHP module fails to load, only your front-end controller's code will be exposed. The rest will remain hidden.

  • I highly suggest you to make use of a namespace based auto loader (e.g. the PSR-0 autoloader).

With this you don't have to keep adding new folders into your auto loader (referring to the long chain of else ifs in your current auto loader). Instead, you declare them via namespaces in your classes which makes it more efficient and handy. Additionally it prevents conflict between duplicate class names from different namespaces.

  • I don't see no reason why you wouldn't merge your config.php with index.php. They essentially do the same thing; bootstrapping the "framework".

  • Your controllers are tightly coupled to their dependencies. I suggest you make use of Dependency InjectionDependency Injection to couple them loosely. It also makes for easier testing.

  •  
  • Your Registry class introduces global state. Which goes against the principles of OOP.

    The Registry class introduces global state which goes against the principles of OOP and is considered an anti-pattern.

HTML code in the index.php bootstrap file is a big no no.

<a href="index.php?route=login">Login</a> <a href="index.php?route=register">Register</a>

In the MVC pattern all View related logic goes in theit's corresponding View class and HTML in the template.


In the show() method of your View class you're doing:

foreach ($this->vars as $key => $value) {
    $$key = $value;
}

Fortunately extract($this->vars); gets the job done with less code. :)

There are only a couple of things I'd like to say:

  • You might wanna create a new folder public / public_html to store all the application's public files for the web (javascripts, stylesheets, images, front-end controller, etc). Then you can set this folder as your web root so that the rest of your application code remains private. It also has the benefit of when the PHP module fails to load, only your front-end controller's code will be exposed. The rest will remain hidden.

  • I highly suggest you to make use of a namespace based auto loader (e.g. the PSR-0 autoloader).

With this you don't have to keep adding new folders in your auto loader (referring to the long chain of else ifs in your current auto loader). Instead, you declare them via namespaces in your classes which makes it more efficient and handy. Additionally it prevents conflict between duplicate class names from different namespaces.

  • I don't see no reason why you wouldn't merge your config.php with index.php. They essentially do the same thing; bootstrapping the "framework".

  • Your controllers are tightly coupled to their dependencies. I suggest you make use of Dependency Injection to couple them loosely. It also makes for easier testing.

  • Your Registry class introduces global state. Which goes against the principles of OOP.


HTML code in the index.php bootstrap file is a big no no.

<a href="index.php?route=login">Login</a> <a href="index.php?route=register">Register</a>

In the MVC pattern all View related logic goes in the View class and HTML in the template.


In the show() method of your View class you're doing:

foreach ($this->vars as $key => $value) {
    $$key = $value;
}

Fortunately extract($this->vars); gets the job done with less code. :)

There are only a couple of things I'd like to say:

  • You might wanna create a new folder public / public_html to store all the application's public files for the web (javascripts, stylesheets, images, front-end controller, etc). Then you can set this folder as your web root so that the rest of your application code remains private. It also has the benefit of when the PHP module fails to load, only your front-end controller's code will be exposed. The rest will remain hidden.

  • I highly suggest you to make use of a namespace based auto loader (e.g. the PSR-0 autoloader).

With this you don't have to keep adding new folders to your auto loader (referring to the long chain of else ifs in your current auto loader). Instead, you declare them via namespaces in your classes which makes it more efficient and handy. Additionally it prevents conflict between duplicate class names from different namespaces.

  • I don't see no reason why you wouldn't merge config.php with index.php. They essentially do the same thing; bootstrapping the "framework".

  • Your controllers are tightly coupled to their dependencies. I suggest you make use of Dependency Injection to couple them loosely. It also makes for easier testing.

  •  
  • The Registry class introduces global state which goes against the principles of OOP and is considered an anti-pattern.

HTML code in the index.php bootstrap file is a big no no.

<a href="index.php?route=login">Login</a> <a href="index.php?route=register">Register</a>

In the MVC pattern all View related logic goes in it's corresponding View class and HTML in the template.


In the show() method of your View class you're doing:

foreach ($this->vars as $key => $value) {
    $$key = $value;
}

Fortunately extract($this->vars); gets the job done with less code. :)

deleted 101 characters in body
Source Link
Kid Diamond
  • 2.6k
  • 16
  • 35
Loading
deleted 101 characters in body
Source Link
Kid Diamond
  • 2.6k
  • 16
  • 35
Loading
Source Link
Kid Diamond
  • 2.6k
  • 16
  • 35
Loading