PHPackages                             amirhb/hipersia - 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. amirhb/hipersia

ActiveLibrary[Framework](/categories/framework)

amirhb/hipersia
===============

A Micro-MVC PHP-Framework

026PHP

Since Mar 24Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Amirhb/hipersia)[ Packagist](https://packagist.org/packages/amirhb/hipersia)[ RSS](/packages/amirhb-hipersia/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Hipersia
========

[](#hipersia)

Hipersia is a Micro-MVC PHP-Framework. It's been developed as a technical research as journey for me to get a better idea of MVC Web-frameworks. Hipersia is completely functional as a framework and as an example, I developed a simple [Shoutbox app](https://github.com/Amirhb/hipersia-sample-shoutbox "Shoutbox Web-App by Hipersia Micro-MVC PHP-Framework") using it.

Installation
------------

[](#installation)

### Composer

[](#composer)

You could use [Composer](https://getcomposer.org/download/ "Composer") to install Hipersia and all needed dependencies.

```
{
  "require": {
    "amirhb/hipersia": "dev-master"
  },
...

```

Configuration
-------------

[](#configuration)

### Database

[](#database)

The config folder of the project's root is the only hard-coded path you would need in your project due to database settings. There should be a config.yml file in the config folder of the project's root. You should customize it based your own environment.

```
dsn: mysql://username:password@localhost/databasename
name: mysql

```

Data-Mapping is supported by [Spot ORM](http://phpdatamapper.com "Spot ORM") and you can change dsn and name properties to support other databases which get supported by Spot ORM.

Models
------

[](#models)

Each model-file is a php class which inherited from \\Spot\\Entity .

```
namespace app\models;

class Message extends \Spot\Entity
{
    protected static $table = 'messages';
    public static function fields()
    {
        return [
            'id'           => ['type' => 'integer', 'primary' => true, 'autoincrement' => true],
            'author'       => ['type' => 'string', 'required' => true],
            'message'      => ['type' => 'text', 'required' => true],
            'date_created' => ['type' => 'datetime', 'value' => new \DateTime()]
        ];
    }
}

```

For more information on how to develop a Spot Entity, visit [here](http://phpdatamapper.com/docs/entities/ "Working With Entities").

Migration
---------

[](#migration)

You can run migration to create tables based on your models. Your migration class has to inherit MigrationController of Hipersia like the following example:

```
namespace app\controllers;

use hipersia\framework\MigrationController as Migration;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class MigrationController extends Migration {

    public function index( Request $request, Response $response) {

        $this->migrate('app\models\Message');

        return $response;
    }
}

```

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

[](#controllers)

Each controller inherits hipersia\\framework\\Controller and it uses Response and Request object of HttpFoundation.

```
namespace app\controllers;

use hipersia\Base as base;
use hipersia\framework\Controller as Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use hipersia\framework\AssetBundle;

class DefaultController extends Controller {

    public function index( Request $request, Response $response, $args) {

        echo 'You have called ' . $args['uri'];

        return $response;
    }
}

```

### Routing

[](#routing)

As you see in the sample [Shoutbox app](https://github.com/Amirhb/hipersia-sample-shoutbox "Shoutbox Web-App by Hipersia Micro-MVC PHP-Framework"), you can define new routes. It's based on php league [Route](http://route.thephpleague.com "Route") package. You have to call something like the following when your app starts.

```
use Symfony\Component\HttpFoundation\Request;

$router = new League\Route\RouteCollection;

$router->addRoute('GET', '/migrate', 'app\controllers\MigrationController::index');
$router->addRoute('GET', '/welcome', 'app\controllers\DefaultController::welcome');
$router->addRoute('GET', '/', 'app\controllers\DefaultController::shoutBox');
$router->addRoute('POST', '/', 'app\controllers\DefaultController::shoutBox');
$router->addRoute('GET', '/{uri}', 'app\controllers\DefaultController::index');

$dispatcher = $router->getDispatcher();

$request = Request::createFromGlobals();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());

$response->send();

```

### Working with Models in your Controller

[](#working-with-models-in-your-controller)

To access Spot's mapper. You should use base methods of Hipersia framework as follows:

```
$locator = base::getDbLocator();
$mapper = $locator->mapper('app\models\Message');

```

For more information on database queries provided by mappers, visit [here](http://phpdatamapper.com/docs/queries "Queries With Spot").

```
namespace app\controllers;

use hipersia\Base as base;
use hipersia\framework\Controller as Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use hipersia\framework\AssetBundle;

class DefaultController extends Controller {

    public function shoutBox( Request $request, Response $response) {

        $locator = base::getDbLocator();
        $mapper = $locator->mapper('app\models\Message');

        if(!empty($_POST)) {
            $message = $mapper->insert([
                'author' => $_POST['author'],
                'message' => $_POST['message']
            ]);
        }

        $messages = $mapper->all();

        AssetBundle::registerCss('bootstrap', __DIR__ . '/../views/css/bootstrap.css');

        return $this->render('shoutbox', ['messages' => $messages]);
    }
}

```

Assets
------

[](#assets)

Hipersia provides the AssetBundle class to manage assets like css and javascript files. You can use the following syntax to add your asset to be used in the related view. For Css files:

```
AssetBundle::registerCss($name, $source);

```

For Javascript files:

```
AssetBundle::registerJs($name, $source);

```

$name is the final name that you want to use for your script and $source is the physical address of the file.

View
----

[](#view)

For the view, Hipersia uses [Twig](http://twig.sensiolabs.org/ "Twig") template engine. View files are located in View folder in project's root by default. To render a view, you should use the render method that Hipersia provides like the following:

```
return $this->render($view, $data);

```

$view is the view file's name without it's extension and $data is an array which contains variables which is being passed to the view. For more information how to create twig templates, visit [Twig Documentation](http://twig.sensiolabs.org/documentation "Twig Documentation").

### Using Assets in Views

[](#using-assets-in-views)

To register css and javascript files, like we pointed earlier in this guide, you can use the AssetBundle class before rendering the view.

```
AssetBundle::registerCss('bootstrap', __DIR__ . '/../views/css/bootstrap.css');

```

And to generate related html tags for using assets, you should add the following to the appropriate view template file:

```

    Shoutbox Web-App by Hipersia Micro-MVC PHP-Framework
    {{ assets.renderAssets|raw }}

...

```

### Csrf Support

[](#csrf-support)

Hipersia forces csrf-protection for POST requests. You have to add the following field in your twig template when POST-ing a form:

```

```

Hipersia is in charge of ensuring that if you've sent the correct value. There's no need for you to add any code to check it.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1146341?v=4)[Amir Hossein Babaeian](/maintainers/Amirhb)[@Amirhb](https://github.com/Amirhb)

### Embed Badge

![Health badge](/badges/amirhb-hipersia/health.svg)

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

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k104.3M836](/packages/laravel-socialite)[laravel/dusk

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

1.9k38.6M289](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

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