Giter VIP home page Giter VIP logo

synful's Introduction


StyleCI Latest Stable Version Latest Unstable Version License

Credits


This repository has been archived.

What is it?

Synful is a simple PHP framework that gives you the tools to create a custom web API in minutes.

How can I get it?

Head over to The Wiki Pages for information on how to get Synful and what the next steps are to get your custom API up and running!

Benchmark

On a Vagrant box with 4096MB RAM, 4x CPU, running a LAMP stack using the GetIpExample.php Request Handler.

$ sudo ab -t 60 -c 5 http://127.0.0.1/example/getip
...
Requests per second:    6545.17 [#/sec] (mean)

Preview (RequestHandler)

namespace App\RequestHandlers;

use \Synful\Framework\RequestHandler;
use \Synful\Framework\Request;

/**
 * Example RequestHandler.
 */
class GetIPExample extends RequestHandler
{
    /**
     * Override the handler endpoint
     * Example: http://myapi.net/user/search
     * uses the endpoint `user/search`.
     *
     * @var string
     */
    public $endpoint = 'example/getip';

    /**
     * Handles a GET request type.
     *
     * @param  \Synful\Framework\Request $request
     * @return \Synful\Framework\Response|array
     */
    public function get(Request $request)
    {
        return [
            'ip' => $request->ip,
        ];
    }
}

synful's People

Contributors

nathan-fiscaletti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

elttuercas

synful's Issues

Give API keys security levels

Instead of using API key whitelisting per-request handler, we should be assigning each request handler a security level. Each api key should also be assigned a security level, only API keys with security levels matching that of the request handler should be allowed access to it.

Add Middleware feature, move validation to middleware

Add a middleware feature. Validation.php would be removed, and a Middleware interface would be created. Validation would be moved to a custom implementation of this Middleware, and API Key validation would be moved to a separate Middleware implementation. The regular request validation Middleware will be enforced, but API Key validation will be optional.

Instead of using the $is_public, $white_list_keys, and $security_level properties of the RequestHandler, this would be moved to custom Middleware implementations.

To add middleware to an Endpoint, you would override the $middleware property and set it to an array of the Middleware classes that would be used.

You can create custom middleware by running ./synful -cmw MiddleWareName from console. You would then override the action function of the Middleware object. This will give you access to the Request object.

interface MiddleWare
{
    public function performAction(Request $request);
}

Implement modrewrite

Implement modrewrite to use true URL endpoints instead of passing a RequestHandler with the JSON request.

Add Vagrantfile

We removed the Vagrantfile in v2.0.0, this should be added again.

Add version

Add a version to the library, output using ./synful -v or ./synful -version

Remove the test.php file

There is no need for the test.php file anymore, as modrewrite doesn't allow access to it anyway. Remove this file.

Remove scandir

In a lot of the functions being used to load parts of the framework, we are using scandir to load files. This should be replaced by a configuration entry with the class names.

Refactor Validator

the Synful\Util\Framework\Validator class is very messy and needs to be refactored.

Abstract request into it's own Object

Instead of accessing the request through the Response->Request method that's currently being used, we should create a Request object that gets passed to the RequestHandlers and a Response should be returned from them.

Authentication issue

API Keys get truncated by the password_hash function as it will truncate output hashes to only 72 characters.

Removing salts should fix this issue as password_hash handles salts internally anyway.

Remove Master Key

The master key feature is no longer necessary. It should be removed.

Better Endpoints

Implement a better endpoint management system for RequestHandlers.

Interally, Synful would register each RequestHandler's endpoint as follows.

    \Synfu\Synful::registerEndPoint($requestHandler);

If the endpoint is already being used, an error would be thrown.

Fix StyleCI

The style checks have been failing, need to fix StyleCI and implement merge requirements for StyleCI

Add missing request types

Currently, we only support POST, GET, PUT and DELETE. We should add support for PATCH, and OPTIONS.

Remove Key Permissions

Key permissions are not used. The code for storing them takes up extra unnecessary logic and it should be removed and instead be handled with whitelisting and request handlers.

Respond with proper HTTP response code

Instead of always responding with a 200 and packaging the true HTTP response code in the response body, move it to the response headers where it should be.

Update Wiki

The Wiki for this project is severely out of date. It will need to be updated.

Missing directories

The directories src/Synful/App/Commands and src/Synful/App/Data are missing.

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.