Skip to content

Issue-1 : Init framework MVC #13

@cedb13

Description

@cedb13

I- Staging environment:

  • Introduction: My computer have Windows11 OS that's why i use sub-system WSL2 for to work with ubuntu environment.
    I have integrated my code editor VScode in WSL
  • Configuration required:
    Server software => Apache 2.4.52
    Database management system => Mysql 8.0.31
    Interface database management => Phpmyadmin 5.1
    Main code language code => PHP 8.1.2

When your localhost is installed see http://localhost/info.php for more details (see README file)

II- Create a view model controller:
First, create folders for each entity

A- Global App folder which is composed of :

  • Folders for the models :
    => Model Folder: Contains all the necessary files corresponding to each class model having its own functions and contributing to the preparation of the elements that will be displayed.
    => Lib folder: Files that have functions to establish relationships with the database.

  • Views folders :
    => A folder views which itself contains a folder Templates: each view file necessary to display our application.

  • The Controllers folder: Contains the files necessary to control the global functioning of the application.

  • The Autoloader file: To call an internal function every time an undeclared class tries to create an instance. This saves us from making a require for each different class. Allows to use the name_space to call the function of a class in another class.

B- Public folder: Contributes to the display of views and their design.

-> Index file: Allows to send to the views the data passed by the controllers.
Also allows the controllers to retrieve the data dropped on the application interface.

-> css folder

-> js folder

-> media folder

III- Init

A- In App folder

To create Autoloader.php

Prepare main Models:

In folder Lib =

  • Database.php => for PDO connection and fetch database line
  • App.php => Single instance for a single database server connection, for get single object ...
    Help to get and set elements for exchanges with database

In Model folder =

  • Table.php => create main functions for prepare the query and retrieve the need elements we can find in database
  • Home.php => Extend Table class for create functions that will can to contribute to find or create elements for the home page when they are call by controller

Prepare main views:

In templates folder to create =

  • defaut.php => view that display header and footer for our blog
  • home.php => view that display home page

Prepare main Controllers:

In Controllers folder to create =

  • Controller.php => It is used as a base for other derived controllers, in our case for ClassControllers
  • HomeController.php for start and after the all File ClassController according to the needs => They receive user events (depending on their role) and trigger actions to be performed. If an action requires a data change, the ClassController requests the data change from the model and then notifies the view that the data has changed so that the view can update itself.-

B- In public folder
To create =

  • index.php => trigger the autoloader and receives the controllers action
  • css folder => Style sheets for the appearance of our website
  • js folder => to make dynamic our content, our appearance
  • media folder => for pictures, pdf document, font awesome icons ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions