I made my own simple php framework inspired from laravel framework.

Related tags

Frameworks php laravel
Overview

Simple MVC

About

Since 2019, I started learning the php programming language and have worked on many projects using the php framework. Laravel is one of my favorite php frameworks. I made this simple framework inspired by the laravel framework.

Version 1.0.0

Requirenment PHP >= 5.6

You can see the application with the url below.

https://alam-simplemvc.000webhostapp.com/

Table of Contents

Setup

First you need to clone this package.

git clone https://github.com/rizkyalam/simplemvc.git

Or you can download this package from github.

Then you must setup database and base url in file .env

Route

You can add static and dynamic routing using $router->get() in file app/configs/routes.php. $router->get() have two parameters first for url and second for the controller with two indexes, first index for class controller name and second index for method controller.

For example you can see the code below.

// static route
$router->get('/static', [HomeController::class, 'index']);

// dynamic route using curly brackets
$router->get('/foo/{bar}', [HomeController::class, 'foo']);

Model

First you need add namespace App\Models for your Model and then you must inheritance class from Core\Model.

Model Propeties

$table is for access database table.

$primary_key is for point to primary key of row table with the default is id.

$fillable list of table rows to be insert or update

Model Method

create() is for insert a new data to database and have one parameters for data which to insert.

all() is for read all data from database.

get() is for read specified data from database and have two parameters. First parameters is for select rows data which to show, second parameters is for add a basic where clause to the query.

update() is for update the data from database and have two parameters. First parameters is for data which to be updated, second parameters is for specified primary key.

delete() is for delete the data to database and have one parameters for specified primary key.

View

First you need to make a HTML document with extension .php.

If you want to access the data from controller you only have to access with the variable name from key of array data.

For example you can see the code below.

// controller
$data['foo'] = 'bar';
$this->view('home', $data);

// view

$foo

Controller

First you need add namespace App\Controllers for your controller and then you must inheritance class from Core\Controller.

Then you need to display with view you can add with $this->view('home', $data).

If you want to access a model you can add with ModelFactory::table('name')->all().

ModelFactory have a static method that is table() with one parameters of database table name and must be chaining with method of model like get(), create(), all(), update() and delete().

You might also like...
Framework X is a simple and fast micro framework based on PHP
Framework X is a simple and fast micro framework based on PHP

Framework X is a simple and fast micro framework based on PHP. I've created a simple CRUD application to understand how it works. I used twig and I created a custom middleware to handle PUT, DELETE methods.

Sunhill Framework is a simple, fast, and powerful PHP App Development Framework

Sunhill Framework is a simple, fast, and powerful PHP App Development Framework that enables you to develop more modern applications by using MVC (Model - View - Controller) pattern.

Framework X – the simple and fast micro framework for building reactive web applications that run anywhere.

Framework X Framework X – the simple and fast micro framework for building reactive web applications that run anywhere. Quickstart Documentation Tests

FuelPHP v1.x is a simple, flexible, community driven PHP 5.3+ framework, based on the best ideas of other frameworks, with a fresh start! FuelPHP is fully PHP 7 compatible.

FuelPHP Version: 1.8.2 Website Release Documentation Release API browser Development branch Documentation Development branch API browser Support Forum

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.

Slim Framework Slim is a PHP micro-framework that helps you quickly write simple yet powerful web applications and APIs. Installation It's recommended

A simple, secure, and scalable PHP application framework

Opulence Introduction Opulence is a PHP web application framework that simplifies the difficult parts of creating and maintaining a secure, scalable w

Leaf is a PHP framework that helps you create clean, simple but powerful web apps and APIs quickly and easily.
Leaf is a PHP framework that helps you create clean, simple but powerful web apps and APIs quickly and easily.

Leaf is a PHP framework that helps you create clean, simple but powerful web apps and APIs quickly and easily. Leaf introduces a cleaner and much simpler structure to the PHP language while maintaining it's flexibility. With a simple structure and a shallow learning curve, it's an excellent way to rapidly build powerful and high performant web apps and APIs.

Woski is a fast and simple lightweight PHP Framework for building applications in the realm of the web.
Woski is a fast and simple lightweight PHP Framework for building applications in the realm of the web.

Woski is a simple fast PHP framework for the Realm The Project Installation Clone the repository $ composer create-project clintonnzedimma/woski myApp

A simple encapsulation of Web3 framework in PHP environment

Web3 A simple encapsulation of Web3 framework in PHP environment. install composer require kgs/web3 Usage web3 $web3 = new Web3('https://kovan.infura.

Owner
Web Developer
null
💡 Mudrock is a MVC PHP framework, which was inspired by the Laravel and CodeIgniter frameworks.

?? Mudrock is a MVC PHP framework, which was inspired by the Laravel and CodeIgniter frameworks

null 3 Nov 17, 2021
Rori-PHP is custom non production web application framework inspired by Laravel syntax

Rori-PHP is custom non production web application framework inspired by Laravel syntax. A web framework provides a structure and starting point for your application allowing you to focus on creating something amazing.

UnknownRori 5 Jul 28, 2022
This is an attempt at making my own personal PHP framework purely for learning purposes.

PHP-MVC-FRAMEWORK This is an attempt at making my own personal PHP framework purely for learning purposes. Installation Download the archive or clone

Alvin Kigen 3 Feb 5, 2022
This repository include my own PHP MVC Framework

PHP OWN MVC FRAMEWORK Kendimi geliştirmek ve modern PHP Framework'lerinin işleyişini kavram amacıyla inşa ettiğim profesyonele yakın PHP MVC Framework

Yılmaz Kadan 9 Nov 24, 2022
A super fast, customizable and lightweight PHP MVC Starter Framework to extend for your own...

PHPMVC A super fast, customizable and lightweight PHP MVC Starter Framework to extend for your own... How to Start Clone this repo - git clone https:/

Maniruzzaman Akash 9 Dec 11, 2022
Fast PHP framework made with very loose optional components.

Nimble is a super fast mini-framework for PHP built on top of optional loose components. Installation Clone the repository $ git clone [email protected]:

Neo 53 Dec 22, 2022
A set of ready-made regex helper methods for use in your Laravel application.

Regex A set of ready-made regex helper methods for use in your Laravel application. Installation composer require hotmeteor/regex Usage Regex comes wi

Adam Campbell 229 Dec 25, 2022
Simple PHP framework that helps you quickly understand and write simple APIs.

Lightweight-PHP-Framework-For-APIs. Simple PHP framework that helps you quickly understand and write simple APIs. Installation Use the package manager

Youssef Hajjari 24 Jul 22, 2022
Simple PHP framework that helps you quickly understand and write simple APIs.

Lightweight PHP Framework For Web and APIs PHP framework that helps you write quickly simple but powerful web apps and APIs Installation Use the packa

Youssef Hajjari 24 Jul 22, 2022
CleverStyle Framework is simple, scalable, fast and secure full-stack PHP framework

CleverStyle Framework is simple, scalable, fast and secure full-stack PHP framework. It is free, Open Source and is distributed under Free Public Lice

Nazar Mokrynskyi 150 Apr 12, 2022