A php mvc framework build on top of phpgram

Installs: 3 006

Dependents: 0

Suggesters: 0

Security: 0


1.5.3 2020-08-07 10:19 UTC

This package is auto-updated.

Last update: 2023-03-07 20:24:40 UTC


phpgram mvc project

Packagist Version PHP from Packagist Packagist

A fast and lightweight Mvc framework

Build on top of phpgram micro framework


  • Simple and fast Http Routing

  • Psr 7 Request and Response with Nyholm

  • Psr 15 Middleware support

  • Psr 17 Factory with Nyholm

  • Dependency Injection with Psr 11 Container. Container from pimple

  • Php Template System

  • Basic Login, Authentication and Usermanagement via Php Session (or Psr 16 Cache)

  • Basic Psr 7 Cookies

  • Async Requests ready


via composer

composer create-project phpgram/mvc

Initialize / Set up


  1. copy file: env.local.php.dist and rename it to: env.local.php

  2. complete the Database and Path information

    • for ROOT_URL_PATH = the relative Url Path (e.g.: -> /my_folder is the path)
  3. done :)


Change the env.php to your deploy server


Define Routes

//file /routes/web.routes.php

use Gram\Project\App\AppFactory as Route;

use App\Http\Controller\DummyController;

//With function as handler
// for Url: / its return: This page is the Start
Route::get("/",function (){
	return "This page is the Start";

//with Controller (Class) as handler
//at Url: /controller: instantiate class DummyController (incl Dependency Injection) and call the method dummyFunction()

//call this method with the value of id

Define Controller

//file: app/Http/Controller/DummyController.php

namespace App\Http\Controller;

use Gram\Mvc\Lib\Controller\BaseController;

class DummyController extends BaseController
	private $tpl = 'index.temp';	//template without the .php!

	public function dummyFunction()
		return $this->view($this->tpl,[
			'msg'=>"Test Controller"
	public function dummyFunctionWithArgs($id)
		return $this->view($this->tpl,[

Define Templates

	//file index.temp.php
$this->extend('defaultview'); //Values will being save for defaultview

$this->assign('h1',"Headline");	//assign variable h1 with the value Headline

//assign multiple variables at once
	'title'=>"Test page",

//Starts a section. The content will be buffered
	<script type="text/javascript">
		alert("Hello! I am an alert box!!");

//the content of this section will be available as variable head

<?php $this->start();?>
	<h2>Test Template</h2>
	<p>Welcome to phpgram mvc framework!</p>
<?php $this->end('content');?>

	//file defaultview.php


	<?= $title?>
	<?= $head?>

	<h1><?= $h1?></h1>
	<div class="content">
		<p> <?= $content?> </p>
    	<?= $my_awesome_button?>



phpgram is open source and under MIT License