2017 © Pedro Peláez
 

library horus

A micro PHP7 framework

image

alash3al/horus

A micro PHP7 framework

  • Friday, July 1, 2016
  • by alash3al
  • Repository
  • 10 Watchers
  • 58 Stars
  • 68 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 21 Forks
  • 0 Open issues
  • 13 Versions
  • 0 % Grown

The README.md

Horus 15

Horus 15 is a new light and simple version of Horus Framework ., (*1)


Quick Overview

<?php

    // load Horus
    require "Horus.php";

    (new \Horus\App)->on("/", function(){
        // the first param is an array of key => value
        // for the header field => value
        // the value may be an array "will be appended"
        // the second param "optional" to set the response status code .
        $this->header([
            "x-powered-by" => "Horus"
        ], 200);
        echo "Hello World";
    });


API Summary


<?php require "Horus.php"; // Initialize Horus with optional configurations $app = new \Horus\App([ // Force all urls/cookies to be secured "https" // Note, Horus will try to detect whether the request is done over // https or not, but this will force it to be yes or no // "just if you need" "secure" => true, // Force horus to generate routes with "/index.php/" in urls // this settings is only if your server doesn't support // url rewriting "index" => "/index.php/" ]); // See the following examples for the usage of the router // handle a request that needs the see "Hello GET" to be displayed // under only GET method $app->on("GET /test", function(){ echo "Hello GET"; }); // Display Hello JSON just for a POST request $app->on("POST /json", function(){ $this->header(["content-type" => "application/json"]); echo json_encode([ "message" => "Hello JSON" ]); }); // named params ? $app->on("/post/([a-z]+)/([0-9]+)", function($word, $num){ echo $word . " : " . $num; }); // execute multiple functions/layers ? // each function will be executed after the previous one is ended // if a function returned false, the chain will be break, // the result of each function will be the last param of the next function in the chain . $app->on("/page/([^/]+)", [ function($page){ echo "layer 1 <br />"; return "test"; // or return false to cancel the execution of the next function }, function($page, $result){ echo $result; } ]); // access the configs // you can also create/access anything inside horus // because it extends stdClass and adds __call() to it $app->configs; // callback $app->func = function(){ // your can access horus using // $this from here too ! echo "ok"; }; // call it $app->func(); // check whether the request is under https or not // it will consider the request secure if you forced it // from the configurations $app->secure(); // i need to get full url for "/assets/css/style.css" $app->url("/assets/css/style.css"); // it will return a url with scheme "http or https" and hostname // if you want to change the host ? // also if you want to change the scheme from http to https "secure" // the last param is for secure or not "https or not" // the last param will be automatically set for you using // $app->secure() $app->url("/assets/css/style.css", "my.domain", false); // but if you want to get a url to an internal route ? // just change the ->url to ->route // also you can change the resulting host and scheme "secure or not" $app->route("/post/", "my.domain", false); // view some html template(s) $app->view(["tpl.php"], ["var" => "val"]); $result = $app->view(["tpl.php"], ["var" => "val"], true); // get Horus instance ? Horus::getInstance(); // how about autoloads ? $app->autoload("./vendor/"); // now play with your libraries ! // or multiples sources: $app->autoload(["./vendor", "./components"]); // you can create your own object container using horus new stdClass // or extending it, by default \Horus\App extends it . $app->obj = new \App\stdClass; // or new \App\stdClass(['k' => 'v']); to import some data $app->import([...]); $app->obj->test = function(){ // ... };

The Versions

01/07 2016

v14

14.0.0.0

A micro PHP7 framework

  Sources   Download

MIT

The Requires

  • php >=7

 

psr framework request response router autoload standalone

14/08 2015

v13

13.0.0.0

A micro php 5 framework

  Sources   Download

MIT

The Requires

  • php >=5.4

 

psr framework request response router standalone

12/06 2015

v12.0

12.0.0.0

A micro php 5 framework

  Sources   Download

MIT

The Requires

  • php >=5.4

 

psr framework request response router standalone

17/03 2015

v11.0

11.0.0.0

A portable full stack event-driven micro-framework for express developments

  Sources   Download

The Requires

  • php >=5.3

 

micro framework request restful response express url router

07/02 2015

v10.1

10.1.0.0

A portable full stack event-driven framework for express developments

  Sources   Download

MIT

The Requires

  • php >=5.3

 

framework rest http pdo router express classloader portable horus

26/01 2015

v10

10.0.0.0

A portable full stack event-driven framework for express developments

  Sources   Download

MIT

The Requires

  • php >=5.2.17

 

framework rest http pdo router express classloader portable horus

17/01 2015

v9.4.1

9.4.1.0

A portable full stack event-driven framework for express developments

  Sources   Download

MIT

The Requires

  • php >=5.2.17

 

framework rest http pdo router express classloader portable horus

15/01 2015

v9.4

9.4.0.0

A portable full stack event-driven framework for express developments

  Sources   Download

MIT

The Requires

  • php >=5.2.17

 

framework rest http pdo router express classloader portable horus

05/01 2015

v9.3

9.3.0.0

A portable full stack event-driven framework for express developments

  Sources   Download

MIT

The Requires

  • php >=5.2.17

 

framework rest http pdo router express classloader portable horus

03/01 2015

v9.2

9.2.0.0

A portable full stack event-driven framework for express developments

  Sources   Download

MIT

The Requires

  • php >=5.2.17

 

framework rest http pdo router express classloader portable horus

27/12 2014

v9.1

9.1.0.0

A portable full stack event-driven framework for express developments

  Sources   Download

MIT

The Requires

  • php >=5.2.17

 

framework rest http pdo router express classloader portable horus

08/12 2014

v9

9.0.0.0

A portable full stack event-driven framework for express developments

  Sources   Download

The Requires

  • php >=5.2.17

 

framework rest http pdo router express classloader portable horus

21/11 2014

V8

8.0.0.0

Light & tiny miccro PHP framework scales from small to big applications

  Sources   Download

MIT

The Requires

  • php >=5.2.17

 

framework rest http pdo router portable horus