Siler

⚡ Flat-files and plain-old PHP functions rockin'on as a set of general purpose high-level abstractions.
Alternatives To Siler
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Hoppscotch51,786117 hours ago1March 22, 2022150mitTypeScript
👽 Open source API development ecosystem - https://hoppscotch.io
Postgraphile11,95576997 days ago156May 25, 202267mitTypeScript
Execute one command (or mount one Node.js middleware) and get an instant high-performance GraphQL API for your PostgreSQL database!
Up8,68768133 months ago11March 02, 2018291mitGo
Deploy infinitely scalable serverless apps, apis, and sites in seconds to AWS.
Vscode Restclient4,323
a month ago431mitTypeScript
REST Client Extension for Visual Studio Code
Vulcain3,35824 months ago15October 14, 202122agpl-3.0Go
Fast and idiomatic client-driven REST APIs.
Use Http2,27752917 days ago101September 12, 202285mitTypeScript
🐶 React hook for making isomorphic http requests
Best Of Web Python1,914
6 days ago1cc-by-sa-4.0
🏆 A ranked list of awesome python libraries for web development. Updated weekly.
Awesome Asgi1,296
a day ago11cc0-1.0Python
A curated list of awesome ASGI servers, frameworks, apps, libraries, and other resources
Dream1,138
3 days ago93mitOCaml
Tidy, feature-complete Web framework
Siler1,126198a year ago43January 27, 202128mit
⚡ Flat-files and plain-old PHP functions rockin'on as a set of general purpose high-level abstractions.
Alternatives To Siler
Select To Compare


Alternative Project Comparisons
Readme

I'm afraid that I'm not being able to keep Siler up-to-date as it deserves, so it's repository has been archived.

As an alternative for Siler, something lightweight and simple that works as a library with Swoole out-of-the-box, I highly recommend Nano! Check it out: https://nano.hyperf.wiki/#/en/










Build codecov Psalm coverage Latest Stable Version Total Downloads License

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()
     */
    public static 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

Popular Http Projects
Popular Graphql Projects
Popular Networking Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Psr 11
Psr 2
Psr 15
Psr 4
Php
Psr 7
Http
Http2
Graphql
Websocket
Benchmark
Routing
Micro Framework
Swoole
Flat File