2017 © Pedro Peláez
 

library viper-framework

A lightweight multi-purpose PHP MVC framework

image

arsengoian/viper-framework

A lightweight multi-purpose PHP MVC framework

  • Thursday, June 28, 2018
  • by arsengoian
  • Repository
  • 1 Watchers
  • 1 Stars
  • 39 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 8 % Grown

The README.md

Viper

Viper is a lightweight universal PHP MVC framework with its own models and templating engine, (*1)

Starting developing on Viper is as easy as typing in the console:, (*2)

composer create-project arsengoian/viper PROJECT_NAME dev-master

and configuring DB credentials., (*3)

To check out the application build which is deployed with this command (or contribute) check out: https://github.com/arsengoian/viper, (*4)

Configuration

The web application is configured by an array of YAML files at config/ directory. They contain a list of instructions on every setting. local.yaml contains configuration related to the current server environment while global.config sets up overall application settings., (*5)

Settings may be accessed at any time using Config class:, (*6)

if (Config::get('DEBUG'))     // From local.yaml -> local.yaml and global.yaml don't need a preffix
    return Config::get('Bots.VERIFY_TOKEN')    // From bots.yaml

Features

YAML routing

Requests are routed automatically, for example a GET request to http://website.com/chairs will invoke the get method of ChairsController, (*7)

Routing example:, (*8)

welcome: DefaultController         # directs DOMAIN/welcome -> DefaultController::get($http_params)
hello: DefaultController.main      # directs DOMAIN/hello   -> DefaultController::main($http_params)
products:                          # 1-level hierarchies are also supported
    parse: DefaultController
    count: DefaultController.main

Easy-to-use controllers and built-in validation

A controller function implementing a POST request:, (*9)

public function post (...$args): ?Viewable
{
    $v = new Required($this -> params());                                 // Create validator
    $v -> email('email');                                                 // Validate "email" field

    Client::registerWithImages($this -> params(), $this -> files());      // Create new model in the database
    return new RedirectView('/');                                         // Redirect to main page
}

Auto-completing models

Viper deals with databases automatically, miminizing the need to edit SQL manually. A YAML setup like this:, (*10)

 allowOverwrite: true

 fields:
  fname: VARCHAR(255) NOT NULL
  lname: VARCHAR(255) NOT NULL
  email: VARCHAR(255) NOT NULL
  age: INT NOT NULL
  img: TEXT NOT NULL

will create the needed database structure if needed and update it along with the file if needed., (*11)

Filters

Will be applied to all routes before any controller actions:, (*12)

class Application extends \Viper\Core\Application
{
    /**
     * Defines the list of filters to be run
     * before any controller actions
     * @return FilterCollection
     */
    protected function declareFilters (): FilterCollection
    {
        return new FilterCollection([
            LocalizationFilter::class,
            Authorization::class
        ]);
    }
}

Logging and utilities

Viper supports built-in logging and a collection of useful utilities, including caching, advanced string handling etc., (*13)

Caching capabilities

All views and parsed .yaml files are recovered, if possible, from cache, (*14)

Features in early development

  • Background processes and services
  • Windows background tasks
  • Viper templating engine
  • Console commands
  • Full Mysql support
  • Full SQL Server support
  • Other SQL dialects support
  • Numerous feature and structure improvements

Contributing and development

Since the framework is on an early stage of development, it may feature structural irreversable changes without reverse compatibility., (*15)

Please contribute to the project if you also feel passionate about making PHP development more elegant and intuitive =), (*16)

The Versions

28/06 2018

dev-master

9999999-dev

A lightweight multi-purpose PHP MVC framework

  Sources   Download

Apache-2.0 Apache License 2.0

The Requires

 

by Arsen Goian

framework viper

11/02 2018

dev-bot-fixes

dev-bot-fixes

A lightweight multi-purpose PHP MVC framework

  Sources   Download

Apache-2.0 Apache License 2.0

The Requires

 

by Arsen Goian

framework viper

11/02 2018

dev-sql

dev-sql

A lightweight multi-purpose PHP MVC framework

  Sources   Download

Apache-2.0

The Requires

 

by Arsen Goian

framework viper

21/01 2018

0.2

0.2.0.0

A lightweight multi-purpose PHP MVC framework

  Sources   Download

Apache License 2.0

The Requires

 

by Arsen Goian

framework viper

18/12 2017

0.1

0.1.0.0

A lightweight multi-purpose PHP MVC framework

  Sources   Download

Apache License 2.0

The Requires

 

by Arsen Goian

framework viper