Giter Club home page Giter Club logo

cj-mvc's Introduction

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 [email protected]

Contributors

@Chaitya62

@JigarWala

cj-mvc's People

Contributors

chaitya62 avatar itsjwala avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.