Coder Social home page Coder Social logo

ugly's Introduction

Ugly REST API PHP Framework

Ugly is a single file REST API for PHP including authentication/authorization that is usable without server URL re-writes or from the dev server without a router script. All routing is done through query parameters. Hence the name.

Example

File name: example.php

<?php
include_once "ugly.php";

$api = new Ugly();

$api->get(["greetings"],function($name){
        return "Hello " . $name;
    })

    ->get(["salutations"],function($name){
        return "May your loins be full of fruit great " . $name;
    })
    ->withAuth()

    ->get([],function($_){
        return "Hello World!";
    })
    
    ->execute();
?>

A HTTP GET request to example.php will get the response "Hello World!".

A HTTP GET request to example.php?greetings=Stibbons will get the response "Hello Stibbons".

A HTTP GET request to example.php?salutations=Stibbons will get the response "May your loins be full of fruit great Stibbons" provided that the user is first signed in.

Features

  • Support for GET, POST, PUT and DELETE requests
  • Built-in Authentication and role-based and/or scope-based Authorization
  • Support for routing on optional parameters
  • JSON responses by default
  • Ugly routes

How to use

Please refer to the manual or check the files src/tests/api.php, src/tests/auth.php, src/tests/protectedapi.php for some examples. Keep in mind that those are there for test purposes though.

Ugly is too Ugly?

If Ugly is too ugly for you, check out these Single File API frameworks:

ugly's People

Contributors

prog-re avatar

Stargazers

Mohamad Ibrahim avatar  avatar Jose Simas avatar Motyar avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.