Skip to content

An attempt to make a simple MVC from scratch in PHP

License

Notifications You must be signed in to change notification settings

Chaitya62/CJ-MVC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CJ-MVC-logo

An attempt to make a simple MVC from scratch in PHP

Features

  • Handle get/post easily
  • Model Supports - Create, Read, Update, Delete and where clause.
  • Easlly load views from controller
  • Light Weight
  • Doesn't contain fancy features that you don't use anyways.

How to use

Setup

Just clone this repository

git clone https://github.com/Chaitya62/CJ-MVC.git

OR

Download it and place it in the htdocs equivalent of your server.

Edit the database.php inside config folder to connect it to your sql database.

How it works

The MVC follows a CodeIgniter like url structure.

For Example In the following url http://localhost/CJ-MVC/index.php/User/get/2/

  • CJ-MVC is the project name
  • index.php is compulsory for now as it is the entry point to the app
  • User is the name of the Controller
  • get is the function you want
  • rest is passed as arguments to the function

Note As the function name is get_get and not get the _get means that want this function to handle the get requests.

Controller

To create your own controller just copy the Test.php file in the controller directory and build upon it.

require_once(__DIR__.'/../model/TestModel.php'); replace this line with your model if you have any or remove it. also replace the constructor accordingly

Model

To create your own model copy the TestModel.php file in the models directory. For further examples on using model see the usage in User.php

Views

To create your own view just create simple php views and load it using load_view function in the controller

$this->load_view('<view name>', <associative array for variables you need in the view>)

That's it you are ready to roll and create the next best site.

Sawaal

An app created using this framework demo github

For more details on how the framework works go through the given example files in controller, model and view folders.

Here is a blog post explaining this in detail.

Help Us

This framework is in the very early stages of it's development.

You can help me by posting issues.

or write me at chaitya.shah@somaiya.edu

Contributors

@Chaitya62

@JigarWala

About

An attempt to make a simple MVC from scratch in PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published