Hello everyone!
This page is demo of MVC skeleton that you can use to develop a website based on MVC architecture.
How to install the skeleton?
It is a short instruction that demonstrates how to install this package on your site.
Downloading
- First you need to download the MiMiMi installation package from its official website.
- Then you need to extract this package to your computer.
- Next, copy the extracted package files to the root folder of your site.
Installing
-
Open the home page of your site in a browser. You will see the initial page for installing the package. That page looks like this.
-
Go to the next page of the installer. There is a drop box with application variants. You need to select
mvc.skeletonthere as shown in the following screenshot
You may also enter a different directory name in the left input box if you want to change the default directory
mimimi.app/for your application.
-
Go to the next page of the installer where you should select a default theme if the app you are installing has more than one theme.
You do not need to do anything here because this application has only theme named
default. Just clickNextbutton.
-
This application requires two modules only. You must select them as shown in the screenshot.
These modules are:
Helper- to install the module filemimimi.modules/Helper/Helper.php, it is used to load some primitive functions designed for web page templates.
Url- to install the module filemimimi.modules/Url/Url.php, it is used to parse parts of the requested URL.
-
Now the installer will prompt you to configure the database.
You don't need to do anything here since this app does not use a classic database. Just click
Nextbutton to complete the installation.However, if your future application needs access to the database, you should configure it during this installation step.
That's all!
The result will look like this
After installation
Most likely, you are installing this skeleton to develop your own web application. Therefore, the demo controllers and models included in the installation package won't work for you. You should remove them from the following folders and place your own controllers and models there:
- mimimi.app/Controllers
- mimimi.app/Models
Theory
Model-View-Controller (MVC) is one of the concepts for building applications that originated in 1978 and became widely used on the Internet after 1996. In our case, we're talking about the simple concept of a web application that contains multiple sets of controllers, models, and views, and these three components can be requested through a URL in any combination.
Controller
In this architecture, the controller is used to implement some form of user interaction with website data. For example, an editing form, a full listing of entries, a list divided into subpages, and so on. In other words, it answers the question "What do we want to do?"
Model
The model defines the type of data and the methods for interacting with it. The model answers the question: "What data will we operate with?"
View
The view determines how the result obtained during the current request will be returned. For example, as an HTML page, as a JSON package, as a spreadsheet file, and so on. In other words, it answers the question: "How should the result be packaged?"
Did you know?
Since this application skeleton was initially supposed to have at least a home page, a corresponding controller was immediately created for it. Its name, quite logically, was Home. Accordingly, this controller, implemented as a simple module, was located in the file mimimi.app/Controllers/Home/Home.php.
It contains only one little method run() to render the home page according to additional parameters that could be present in the incoming URL. The controller named Home is written in such a way that it can be binded to another view, for example, named Text, just via its URL. This behavior is consistent with true MVC architecture.
Explain an example
To demonstrate this functionality, two different views were created:
Html- to display the homepage as a classic HTML page generated using themimimi.app/Themes/default/home.tpltemplate file.
Text- to print the same page as its source code.
So we get the following two URLs:
https://your.site/home/as-html - where the first segment "home" means that we are requesting a controller named
Home, and the last segment "as-html" means that we want to bind it to a view namedHtml.
https://your.site/home/as-text - this URL means that we want to bind the
Homecontroller to a view namedText.
Click on the second URL to see the result of this binding.
By the way
Any other URL that attempts to bind the homepage controller to a view other than the two mentioned above (let's say JSON, for example, - https://your.site/home/as-json) will result in a "404 Error" page. Because the Home controller's method run() doesn't have a rule that allows pairing the controller with a view named JSON.
Another Links
https://your.site/ - go to homepage.
https://your.site/home/as-text - print the homepage's source code.
https://your.site/list - go to the list of persons.
https://your.site/list/as-json - get page 1 of persons as JSON package.
https://your.site/list/for-cars - go to the list of cars.
https://your.site/list/for-cars/as-json - get page 1 of cars as JSON package.
https://your.site/robots.txt - print robots.txt document.
https://your.site/sitemap.xml - print sitemap.xml document.