Build a PHP MVC Application: Introduction (Part 1/9)
Why Stack Overflow recommends it
Stack Overflow users link it when someone needs a simple, framework-free walkthrough of MVC structure and URL routing in PHP.
Recommended by 8 people across 9 different months, 2014 to 2020.
What it is
The first of a nine-part Codecourse series in which Alex Garrett builds a plain-PHP MVC application from scratch, without a framework. This 3m44s opener introduces the project and what the series will cover, including front controller routing and .htaccess URL rewriting.
What people said
Recommends user3620691 · 2014-05 · Stack Overflow · on “Url rewriting PHP APACHE”
Thanks for the help. If somebody is interrested, I learned the concept with a simple tutorial (no advertising, I just think he's good teacher ^^) : [this video]
Recommends Jens A. Koch · 2015-03 · Stack Overflow · on “How to Link PHP Sub Categories(Pages) Dynamically”
Before i write a book on MVC explaining and repeating all the things. I just point you to a video tutorial which addresses MVC and application design: [this video] It consists of 9 parts and should get you started really fast. The code for the example is over here: [LINK]
Recommends JosefPP · 2016-01 · Stack Overflow · on “PHP Url Routing separate Dir”
You simply want an MVC. I highly suggest you to follow this tutorial series. No frameworks used, yet working. [this video]
Recommends Beeelze · 2016-05 · Stack Overflow · on “MVC and respecting SOLID”
Just about a year ago I started creating web applications using the MVC design pattern. I started my journey with these series [this video] which provided me with some handles to create my own MVC application. Very basic, but straightforward. Then I stumbled upon the S.O.L.I.D. principles defined by Robert C. Martin. Just by learning each principle apart I get how I could write maintainable code for the future. That's when I found out I have been breaking all 5 principles on a daily basis, but just because my code works I didn't try to respect them at all. So why not combine MVC with SOLID? This presentation [LINK] by Stefan Priebsch gave me some insight on how to mix them together. Stefan propos
Recommends Jethro Hazelhurst · 2016-07 · Stack Overflow · on “URL Routing to single Index File”
You want to look at how a simple php framework works, basically every request is passed to an index.php file in your root directory and then routes are defined by your URLs using (guess what!) a router... Some things you will encounter are. 1 - the front controller patter 2 - the MVC pattern 3 - Controllers and Methods (which are also known as functions) So basically your typical URL route would look like this [LINK] This translate to [LINK] Your controller is a php class , the action is a function in that class and the parameter is any data you want to pass in (for example an id). All frameworks need routing and routing solutions range from relatively simple to very complex. I recommend thi
Recommends Jethro Hazelhurst · 2016-10 · Stack Overflow · on “dynamic php short url”
This is a hard tutorial to wrap your head around in the beginning, at least it was for me, it helps you make a simple router... [this video] However I strongly suggest getting into a framework (and learning about composer) because they have inbuilt routers that are much more reliable then anything a learner could produce...
Recommends Ahmad Tahhan · 2017-09 · Stack Overflow · on “PHP MVC structure and dynamic URL re-writing”
I have followed a youtube playlist to build a simple MVC framework based on PHP, here is a link [this video] to the playlist I have followed. and here is an image of my application structure enter image description here [LINK] I have connected the application to a MySql database, everything is working fine, but now I am trying to do friendly URLs. Currently, my URLs look like the following: mywebsite.com/home/listings/ this is fine as this link is for a static page, but I want the same for dynamic URLs, for example: Current URL: mywebsite.com/home/listings/apart?id=10 to URL: mywebsite.com/home/listings/apart/id/10 I have tried a lot of methods in htaccss but the data is not pulled from the datab
Recommends soul · 2019-01 · Stack Overflow · on “Renaming my PHP website URL using htaccess”
I used MVC architecture pattern to do that. here are some starter resources that can get you where you need to be. There might be better ways to that but this is one way. Starter Code: panique/mini [LINK] main routing Algorithm [LINK] To give the gist of the algorithm here is the .htaccess file inside the Public folder. # If the following conditions are true, then rewrite the URL: # If the requested filename is not a directory, RewriteCond %{REQUEST_FILENAME} !-d # and if the requested filename is not a regular file that exists, RewriteCond %{REQUEST_FILENAME} !-f # and if the requested filename is not a symbolic link, RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ index.php?url=$1 [
Recommends Baracuda078 · 2020-06 · Stack Overflow · on “how do I split this php file into MVC format?”
Models are for database, View to render html, Controllers to handle a request Beside that you can have helper classes and core classes Follow some tutorials on how to create a mvc. [this video] [LINK] I followed the one of Curtis Parham he explained everything very well. After completing his tutorial I modified his framework alot by including composer, twig and changed the routing on how to handle variables and multiple languageses.
Cites kemicofa · 2015-03 · Stack Overflow · on “Is there a standard way of programming in HTML5/js/PHP/CSS to create reusable objects?”
It is unclear exactly what you're asking but here is my answer to what I understood. Server Side Organization: If you were to create a big project I highly advise you to use a PHP framework ( symphony [LINK] , codeigniter [LINK] , etc ), now if you're not then consider the following: 1. Follow MVC structure The MVC structure can be represented multiple different ways. However, keeping it simple, you can do this by creating 3 folders ( controller, model, view ). Each folder will consist of different php files with a specific job. Controller: A controller is the link between a user and the system. It provides the user with input by arranging for relevant views to present themselves in appropri