+ 1

Mvc architecture for an php project ?

I wanna know what are the folders that i should add in my mvc architecture . I had create a models folder , controller folder and view folder what are other things should i add and why ? Thanks for ur help guys

3rd Jan 2021, 6:27 PM
Nassera
Nassera - avatar
1 Answer
+ 1
Usually people use an existing MVC framework instead of creating their own like you seem to be doing. Laravel is the most popular MVC framework for PHP right now. Using an existing MVC framework would give you more practical skill and knowledge of the MVC pattern than creating your own framework from scratch. A routes folder is used by Laravel. This is where HTTP request paths are associated controllers and controller methods. You don't need this but it could be useful if you want routes that don't match perfectly with controller names, folder names, and method names. CodeIgniter opted to not have any route configurations like this. CodeIgniter went with a rule that HTTP request paths should match the paths to controllers and controller methods. A db or migrations folder could be useful. Most web applications connect with a database and updates can require database schema changes or other migrations. For this reason, PHP MVC frameworks such as Laravel include a folder for defining how the associated database is to be migrated. Laravel also includes a "seeds" directory for inserting test or developer data to get a new developer's development environment set up quickly. A "public" or "static" directory could help. You might want a folder where your application will serve static HTML, CSS, JS, and image files. This can save the web developer from configuring that using a custom controller in most applications that he develops. A "tests" directory could help. It is common for projects to come with automated tests. Making that directory standard in your framework can encourage developers to structure their project folders more consistently.
5th Jan 2021, 12:53 AM
Josh Greig
Josh Greig - avatar