PHPackages                             vgalvoso/spm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. vgalvoso/spm

ActiveLibrary[Framework](/categories/framework)

vgalvoso/spm
============

v1.4.0(2y ago)5481[1 issues](https://github.com/vgalvoso/spm/issues)MITPHP

Since Jul 31Pushed 2y ago1 watchersCompare

[ Source](https://github.com/vgalvoso/spm)[ Packagist](https://packagist.org/packages/vgalvoso/spm)[ RSS](/packages/vgalvoso-spm/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)DependenciesVersions (9)Used By (0)

Welcome to (SPM) Simple PHP MVC, just what you need!
====================================================

[](#welcome-to-spm-simple-php-mvc-just-what-you-need)

This is a simple PHP MVC framework without too much dependencies that you don't need.

Supports:
---------

[](#supports)

1. PHP 7^
2. MYSQL
3. MSSQL
4. SQLite

Getting Started
---------------

[](#getting-started)

1. Download the [latest release](https://github.com/vgalvoso/spm/releases) or install via composer \[composer create-project vgalvoso/spm\].
2. Configure your database in app/Config/Database.php.
3. Make sure the project is located inside your web server's root directory.
4. Now you can create Controllers,Views and Models.

Routing
-------

[](#routing)

Creating routes is easy in SPM.

Open routes.php.

Add your new route.

```
//routes.php
use App\Controller\Home;

get('',Home::class,"index");
```

To get data from POST request, use post() function

```
//routes.php
use App\Controller\Home;

//post(route name,class,static function to call)
post('post',Home::class,"samplePost");
```

To get data from GET request, use get() function

```
//routes.php
use App\Controller\Home;

//get(route name,class,static function to call)
get('get',Home::class,"sampleGet");
```

To call cli use cli() function

```
//routes.php sample
cli('comand',Command::class,"executeCommand");
```

Controllers
-----------

[](#controllers)

Controllers responds to hyperlinks,form actions and url inputs.

- Controllers are stored in app/Controller
- Controllers class name must be the same as the file name.

Lets create the function for the "post" route in Home controller.

```
public static function samplePost($post_data){
    //now you can get values from POST request
    //sample: $username = $post_data["username"];
}
```

And for our "get" route.

```
public static function sampleGet($get_data){
    //now you can get values from GET request
    //sample: $id = $get_data["user_id"];
}
```

Views
-----

[](#views)

Views shows information to the user.

- Views are stored in app/Views
- Use snake case for naming views (sample: main\_page.php)
- You can create subfolders to organize your view files.

Let's use our view for Home controller(home route)

```
//app/Controller/Home.php
public static function index()
{
    view("section/header");
    view("home");
    view("section/footer");
}
```

You can pass data to view. (Must be an associative array)

```
//app/Controller/Home.php
public static function index()
{
    $data = ["header" => "Simple MVC Framework",
            "sub_header" => "Just what you need!"];
    view("section/header");
    view("home",$data);
    view("section/footer");
}
```

Keys from the array will be converted into variables that you can use in the views

```
//Views/home.php

```

Models
------

[](#models)

Models are used for CRUD(Create,Update,Delete) operations and SPM made that easy.

- SPM currently supports Transactional Databases (MySql and MsSql).
- Models are stored in app/Model
- Model extends app/Libraries/Model.php

Initialize our model

When we don't place parameter, our model will use the default database.

```
//app/Controller/Home.php
$home_model = new HomeModel();
```

Use other database that is configured in app/Config/Database.php

```
//app/Controller/Home.php
$home_model = new HomeModel("ms");
```

We can also use other database even it is not declared in Database.php

```
//app/Controller/Home.php
$home_model = new HomeModel(null,$host,$user,$pass,$dbname,$driver(mysql/mssql));
```

Select single item

```
//app/Model/HomeModel.php
public function getUser(){
    $query = "SELECT * FROM users WHERE id = 1";
    return $this->getItem($query);
}
```

Select multiple items

```
//app/Model/HomeModel.php
public function getAllUsers(){
    $query = "SELECT * FROM users";
    return $this->getItems($query);
}
```

Anti SQL Injection

```
//app/Model/HomeModel.php
public function validateUser($username,$password){
    $query = "SELECT * FROM users WHERE username = :uname AND pass = :pass";
    $params = ["uname" => $username, "pass"=>$password];
    return $this->getItem($query,$params);
}
```

To Insert data create an assoc array and use table field names as array keys

```
//app/Model/HomeModel.php
public function addUser($username,$password,$firstname){
    $params = ["u_username"=>$username,
            "u_password"=>password_hash($password,PASSWORD_DEFAULT),
            "firstname"=>$firstname];
    if($this->insert("users",$params))
        return true;
    return false;
}
```

To Delete data use exec() function

```
//app/Model/HomeModel.php
public function deleteUser($userId){
    $params = ["id" => $userId];
    $query = "DELETE FROM users WHERE id = :id";
    $this->exec($query,$params);
}
```

To Update data use exec() function

```
//app/Model/HomeModel.php
public function updateUser($firstname,$userId){
    $query = "UPDATE users SET firstname = :firstname WHERE id = :userId";
    $params = ["firstname" => $firstname,"userId"=>$userId];
    return $this->exec($query,$params);
}
```

Start Transaction

```
//inside your model
$this->startTrans();
```

Commit

```
$this->commit();
```

Rollback

```
$this->rollback();
```

Everytime we use our Model functions and it fails, we can get the error

```
$this->getError();
```

We can also see what is the database driver we are currently using.

```
$this->getDriver();
```

And we can also get the last inserted id

```
$this->lastId();
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~56 days

Recently: every ~82 days

Total

7

Last Release

1046d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8464295f7241a874d2583d70fbfe5f56a41ae9ff1e8b60fb1809539b39c382d2?d=identicon)[vgalvoso](/maintainers/vgalvoso)

---

Top Contributors

[![vgalvoso](https://avatars.githubusercontent.com/u/44231964?v=4)](https://github.com/vgalvoso "vgalvoso (31 commits)")

---

Tags

lightweight-php-frameworkphpphp-frameworkphp-frameworksphp-mvc

### Embed Badge

![Health badge](/badges/vgalvoso-spm/health.svg)

```
[![Health](https://phpackages.com/badges/vgalvoso-spm/health.svg)](https://phpackages.com/packages/vgalvoso-spm)
```

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
