snapflowio/framework

A simple and lightweight framework for building PHP apps with Snapflow libraries.

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/snapflowio/framework

v0.1.0 2025-12-16 00:44 UTC

This package is auto-updated.

Last update: 2025-12-16 20:22:23 UTC


README

A simple and lightweight framework for building PHP apps with Snapflow libraries.

Installation

composer require snapflowio/framework

Quick Start

<?php

use Snapflow\Framework\{Framework, Module, Service, Action};
use Snapflow\HTTP\DI\Container;
use Snapflow\HTTP\Http;
use Snapflow\HTTP\Response;
use Snapflow\HTTP\Swoole\Server;

class HelloAction extends Action
{
    public function __construct()
    {
        $this->setHttpMethod(self::METHOD_GET)
            ->setHttpPath('/')
            ->inject('response')
            ->callback(fn(Response $response) =>
            $response->json(['message' => 'Hello World'])
            );
    }
}

class ApiService extends Service
{
    public function __construct()
    {
        $this->setType(self::TYPE_HTTP);
        $this->addAction('hello', new HelloAction());
    }
}

class AppModule extends Module
{
    public function __construct()
    {
        $this->addService('api', new ApiService());
    }
}

class AppFramework extends Framework {}

$app = new AppFramework(new AppModule());
$app->init('http');

$server = new Server('0.0.0.0', 8080);
$container = new Container();
$http = new Http($server, $container, 'UTC');

echo "Server starting on http://localhost:8080\n";
$http->start();

License

This library is available under the MIT License.

Copyright

Copyright (c) 2025 Snapflow