It's been a while since I started Web Developing. My skills in web developing is just an average compare to other programmers. I encountered the idea of MVC
and wanted to apply it on the webpage that I'm currently been doing. Can anyone help/guide on how to integrate MVC to php? Any examples or reference will be a big help to me and to anyone who'll find this thread. :D
Asked
Active
Viewed 91 times
0

Alvin Ching
- 25
- 1
- 7
-
3You can start by going through [this list](https://stackoverflow.com/a/16356866/727208). Just avoid people who tell to learn MVC from frameworks. – tereško Sep 09 '18 at 09:59
-
1@tereško That's like trying to reinvent the wheel before you eventually ditch it and move to a solid framework. Any reason why you downvoted my answer? There is a reason why people use Frameworks for their projects - the support guy doesn't have to spend a year learning 'your' way of doing MVC. No reason to get personal with gasbag arguments. – Venkat D Sep 09 '18 at 10:02
-
2@VenkatD the reason is simple - your recommended frameworks are filled with anti-patterns, abuse global state and promote bad programming practices. Your wheel is square-shaped, and you can't even see it. – tereško Sep 09 '18 at 10:31
-
1Well, @tereško, that's PHP for you. Funnily though, your 'custom' built PHP MVC wheel will only go so far before turning flat, going back to the design board for patching the holes your perfect wheel developed. With CI, you can still work around to the point where the limitations start to show and you have to switch to Laravel or Java/.NET. I know of a 'custom built' Java MVC for a global automobile major which cost them a few million dollars and had to be abandoned for Spring MVC within a year of deployment. Irony aside, the square shaped wheel gets my job done which probably got your goat – Venkat D Sep 09 '18 at 10:55
-
On Friday 14. Sep. 2018 at 15:00 CET you can join an online seminar about it by skype, contact me by skype: david.bruchmann-web. Nevertheless the question is for Stack Overflow to broad and I'll vote for closing it here. – David Sep 09 '18 at 10:59
-
thanks guys for answering my question. @tereško please make your comment an answer to this question. So they could immediately see what's the answer. thanks – Alvin Ching Sep 09 '18 at 11:26
-
@VenkatD In my opinion, a developer with good knowledge of correctly applied principles can familiarize himself with any such "custom-built" app within days. Not to mention that, if all frameworks would follow such principles, their consumers would greatly benefit from the fact. – PajuranCodes Sep 10 '18 at 01:51
-
1I would advise you to develop your own MVC application and I'd complete teresko's resources list with [this](https://stackoverflow.com/a/51735316/9455607) one. In my opinion, if you want to become a good developer, you need to learn by doing. Don't be afraid to reinvent the wheel, because it'll be your wheel, your gained knowledge, your experience. – PajuranCodes Sep 10 '18 at 20:44
-
What do you actually need to "assemble" a web MVC application? First of all to read the recommendations 1, 2, 4, 7, 11, 17 on [php-fig](https://www.php-fig.org/psr/). Then an autoloader ([Composer](https://getcomposer.org/)), a dependency injection container (maybe [PHP-DI](http://php-di.org/)), a router (maybe [FastRoute](https://github.com/nikic/FastRoute)), an implementation of the HTTP message abstraction (maybe [Zend-Diactoros](https://zendframework.github.io/zend-diactoros/overview/)), and, if you wish, a template engine (maybe [Twig](https://twig.symfony.com/)). – PajuranCodes Sep 10 '18 at 20:45
-
Other than that, you'll need your own front-controller implementation. For it, making use of a callable invoker like [this](https://github.com/PHP-DI/Invoker) one will be of great help. I would also advise to use the [PDO](https://secure.php.net/manual/en/book.pdo.php) extension for accessing database data. At this point it will be up to your vision, how your application and business logic will come in play. At last, [here](https://symfony.com/doc/current/create_framework/index.html) is a nice article series, describing how the concerns in a "standard" web page can be separated. Good luck. – PajuranCodes Sep 10 '18 at 20:46
1 Answers
-1
CodeIgniter
is a powerful, lightweight and ridiculously simple to use MVC framework
. You can find it here - https://www.codeigniter.com/
There are others but require a steeper learning curve like Laravel
.
What CodeIgniter lacks (UACL, Authentication
), Laravel makes up for it. You can always use IonAuth with CodeIgniter for simple projects that do not require complicated UACL hierarchies.

Venkat D
- 127
- 1
- 10