Skip to content

CaspiusLabs/SPARK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✨</SPARK>✨

Simple.PHP.Ajax.Request.Kit

Version 2.0.1

This is PHP 5/7 object oriented micro framework, allows to make simple or complex web pages much easier:

  • Specyfically designed to build Single Page Applications (SPA), by easy handling ajax requests or query strings.
  • Very usable for creating Rest API systems.
  • Fast starting point for your web application or website!

Features:

  • Small size, (only four files! yes 4!), fast load times!
  • Vast configurability options, separate config file can be stored in secured dir!
  • Secured with Remove Magic Quotes and Unregister Globals functions!
  • Works with Mod Rewrite pretty urls!
  • Multiple database engines support with PDO!
  • Custom error/fatal error/exception handlers!
  • Development helper functions like NoWrap, TrimAll, ArrayToObject, etc!
  • Easy debugging functions, message boxes, error loggers to file or console.log!
  • It even has simple PHP template system!

Standard request example:

http://localhost/index.php?app=test&param1=val1&param2=val2


Mod rewrite request example:

http://localhost/app/test/val1/val2


jQuery example:

$.ajax({url: "index.php", type: "POST", data: { app: "test", param1: "val1", param2: "val2" }, success: function(data) {...}});

AngularJS example:

$http.get("index.php", {params:{"app": "test", "param1": val1, "param2": val2}}).then(function (response) {...})

React example:

async function getAjax(data) {
  const response = await fetch('http://localhost/index.php?app=test&param1=val1&param2=val2', {
    method: 'POST',
    body: JSON.stringify(data),
    headers: {
      "Content-type": "application/json; charset=UTF-8"
    }
  });
}

Vue.js example:

new Vue({
    el: '#app',
    created() {
        this.fetchData();	
    },
    data: {
        values: []
    },
    methods: {
        fetchData() {
        axios.get('http://localhost/index.php?app=test&param1=val1&param2=val2').then(response => {
            this.values = response.data;
            });
        }
    }
});

PHP Example:

class App extends Spark {

  function ajax_test( $action, $param1, $param2 ) {

    echo "This is test function called from ajax query and this is my values $param1 $param2";

  }

  function test( $action, $param1, $param2 ) {

    echo "This is test function called from url query and this is my values $param1 $param2";

  }

}

Debug and error box messages example:

class App extends Spark {

    function index( $action, $params ) {

        // inside class definition
        $this->error( "No '$action' method defined in Action class!" );

        $this->debug( '$_REQUEST', $_REQUEST );

    }

}

// outside class definition
Spark::error( message );

Spark::debug( variable name, variable );

Result:

spark