All Projects → leocavalcante → Siler

leocavalcante / Siler

Licence: mit
⚡ Flat-files and plain-old PHP functions rockin'on as a set of general purpose high-level abstractions.

Projects that are alternatives of or similar to Siler

Gun
HTTP/1.1, HTTP/2 and Websocket client for Erlang/OTP.
Stars: ✭ 710 (-32.77%)
Mutual labels:  websockets, http2, functional
Armeria
Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
Stars: ✭ 3,392 (+221.21%)
Mutual labels:  hacktoberfest, micro-framework, http2
Cowboy
Small, fast, modern HTTP server for Erlang/OTP.
Stars: ✭ 6,533 (+518.66%)
Mutual labels:  websockets, http2, functional
Vulcain
Fast and idiomatic client-driven REST APIs.
Stars: ✭ 3,190 (+202.08%)
Mutual labels:  graphql, hacktoberfest, http2
Falco
A functional-first toolkit for building brilliant ASP.NET Core applications using F#.
Stars: ✭ 214 (-79.73%)
Mutual labels:  micro-framework, routing, functional
Swell
Swell: API development tool that enables developers to test endpoints served over streaming technologies including Server-Sent Events (SSE), WebSockets, HTTP2, GraphQL, and gRPC.
Stars: ✭ 517 (-51.04%)
Mutual labels:  graphql, websockets, http2
Symfony Docker
A Docker-based installer and runtime for Symfony. Install: download and `docker-compose up`.
Stars: ✭ 732 (-30.68%)
Mutual labels:  hacktoberfest, http2
Sinuous
🧬 Light, fast, reactive UI library
Stars: ✭ 740 (-29.92%)
Mutual labels:  hacktoberfest, functional
Elide
Elide is a Java library that lets you stand up a GraphQL/JSON-API web service with minimal effort.
Stars: ✭ 766 (-27.46%)
Mutual labels:  graphql, hacktoberfest
Farwest
Framework for building RESTful HATEOAS-driven applications.
Stars: ✭ 18 (-98.3%)
Mutual labels:  http2, functional
Restinio
Cross-platform, efficient, customizable, and robust asynchronous HTTP/WebSocket server C++14 library with the right balance between performance and ease of use
Stars: ✭ 694 (-34.28%)
Mutual labels:  library, websockets
Schemathesis
A modern API testing tool for web applications built with Open API and GraphQL specifications.
Stars: ✭ 768 (-27.27%)
Mutual labels:  graphql, hacktoberfest
Xtoolkit.whitelabel
Modular MVVM framework for fast creating powerful cross-platform applications with Xamarin.
Stars: ✭ 22 (-97.92%)
Mutual labels:  hacktoberfest, library
Flix
The Flix Programming Language
Stars: ✭ 719 (-31.91%)
Mutual labels:  hacktoberfest, functional
Mercurius
Implement GraphQL servers and gateways with Fastify
Stars: ✭ 704 (-33.33%)
Mutual labels:  graphql, hacktoberfest
Strawberry
A new GraphQL library for Python 🍓
Stars: ✭ 891 (-15.62%)
Mutual labels:  graphql, hacktoberfest
Mod Pbxproj
A python module to manipulate XCode projects
Stars: ✭ 959 (-9.19%)
Mutual labels:  hacktoberfest, library
Whatpulse
WhatPulse reverse engineered
Stars: ✭ 30 (-97.16%)
Mutual labels:  hacktoberfest, library
Sql To Graphql Schema Generator
⚛️ Generate GraphQL Scheme Online From SQL Query - https://sql-to-graphql.now.sh/
Stars: ✭ 32 (-96.97%)
Mutual labels:  graphql, hacktoberfest
Blaze
⚡ File sharing progressive web app built using WebTorrent and WebSockets
Stars: ✭ 991 (-6.16%)
Mutual labels:  hacktoberfest, websockets









Build codecov Psalm coverage Latest Stable Version Total Downloads License Dependabot Status

Siler is a set of general purpose high-level abstractions aiming an API for declarative programming in PHP.

  • 💧 Files and functions as first-class citizens
  • 🔋 Zero dependency, everything is on top of PHP built-in functions
  • Blazing fast, no additional overhead - benchmark 1, benchmark 2 and benchmark 3

Use with Swoole

Flat files and plain-old PHP functions rocking on a production-grade, high-performance, scalable, concurrent and non-blocking HTTP server.

Read the tutorial.

Getting started

Installation

$ composer require leocavalcante/siler

That is it. Actually, Siler is a library, not a framework (maybe a micro-framework), the overall program flow of control is dictated by you. So, no hidden configs or predefined directory structures.

Hello, World!

use Siler\Functional as λ; // Just to be cool, don't use non-ASCII identifiers ;)
use Siler\Route;

Route\get('/', λ\puts('Hello, World!'));

Nothing more, nothing less. You don't need even tell Siler to run or something like that (puts works like a lazily evaluated echo).

JSON

use Siler\Route;
use Siler\Http\Response;

Route\get('/', fn() => Response\json(['message' => 'Hello, World!']));

The Response\json function will automatically add Content-type: application/json in the response headers.

Swoole

Siler provides first-class support for Swoole. You can regularly use Route, Request and Response modules for a Swoole HTTP server.

use Siler\Http\Response;
use Siler\Route;
use Siler\Swoole;

$handler = function () {
    Route\get('/', fn() => Response\json('Hello, World!'));
};

$port = 8000;
echo "Listening on port $port\n";
Swoole\http($handler, $port)->start();

GraphQL

Install peer-dependency:

composer require webonyx/graphql-php

Schema-first

type Query {
    hello: String
}
use Siler\Route;
use Siler\GraphQL;

$type_defs = file_get_contents(__DIR__ . '/schema.graphql');
$resolvers = [
    'Query' => [
        'hello' => fn ($root, $args, $context, $info) => 'Hello, World!'
    ]
];

$schema = GraphQL\schema($type_defs, $resolvers);

Route\post('/graphql', fn() => GraphQL\init($schema));

Code-first

Another peer-dependency:

composer require doctrine/annotations

Then:

/**
 * @\Siler\GraphQL\Annotation\ObjectType()
 */
final class Query
{
    /**
     * @\Siler\GraphQL\Annotation\Field()
     */
    static public function hello($root, $args, $context, $info): string
    {
        return 'Hello, World!';
    }
}
use Siler\GraphQL;
use Siler\Route;

$schema = GraphQL\annotated([Query::class]);

Route\post('/graphql', fn() => GraphQL\init($schema));

Object type name will be guessed from class name, same for field name, and it's return type (i.e.: PHP string scalar === GraphQL String scalar).

What is next?

License

License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].