2017 © Pedro Peláez
 

library sml-frame

A Tiny framework for handling api's the easy way

image

sml/sml-frame

A Tiny framework for handling api's the easy way

  • Saturday, May 13, 2017
  • by C0mplX
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

SmlFrame

Getting started

run composer install edit the .htaccess file to match your file structure, (*1)

Basic setup

require_once 'vendor/autoload.php';

$app = new Sml\Sml();

# Run the application
$app->run();

ROUTING with request

require_once 'vendor/autoload.php';

$app = new Sml\Sml();

$app::get('/', function(){
  echo 'test';
});

# If you want to pass arguments to the function you do this with regEx values
# Supported values are for Strings and Ints

# String and int value

$app::get('/user/(\w+)/(\d+)', function( $string, $int ){

  # You can then use the params here

});


# POST

$app::post('/user', function() use( $app ) {

  # To get the post request you can do:

  # This recives a json encoded body for you, and returns as obj.
  # If you want a array you can pass true into the json( true )
  $app->request()->json();

  # This recives the x-www-form-urlencoded body ( normal POST )
  $app->request()->body();

});

# Run the application
$app->run();

Response

To use the response obj you need yo inject $app onto your functions, (*2)

require_once 'vendor/autoload.php';

$app = new Sml\Sml();

$app::get('/', function() use( $app ){
  $app->response( 200, "it Works" )->send();
});

# You can also send back json_response by chaining the sendJson method onto the response method.
$app::get('/', function() use( $app ){
  $app->response( 200, "it Works" )->sendJson();
});

$app->run();

Changelog

version 0.0.2 - Added support for POST, GET, PUT, DELETE routes - Added exception class for handling errors - Added Response obj - Added Request obj - Added the use of env file, (*3)

version 0.0.1 - Included simple get Route support., (*4)

The Versions

13/05 2017

dev-master

9999999-dev

A Tiny framework for handling api's the easy way

  Sources   Download

MIT

The Requires

 

by Ole Martin

13/05 2017

v0.0.5

0.0.5.0

A Tiny framework for handling api's the easy way

  Sources   Download

MIT

The Requires

 

by Ole Martin

11/05 2017

v0.0.4

0.0.4.0

A Tiny framework for handling api's the easy way

  Sources   Download

MIT

The Requires

 

by Ole Martin

11/05 2017

v0.0.3

0.0.3.0

A Tiny framework for handling api's the easy way

  Sources   Download

MIT

The Requires

 

by Ole Martin

11/05 2017

v0.0.2

0.0.2.0

A Tiny framework for handling api's the easy way

  Sources   Download

The Requires

 

by Ole Martin