c0pt3r/sonet

!!WIP!! A simple framework for websites/web APIs

Maintainers

Details

github.com/C0PT3R/Sonet

Source

Issues

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/c0pt3r/sonet

dev-main 2025-08-17 12:25 UTC

This package is auto-updated.

Last update: 2025-12-17 13:16:52 UTC


README

A simple PHP framework for creating websites and/or web APIs.

It supports routing of HTTP requests with methods GET, POST, PUT and DELETE. Other things too... maybe one day I'll make a doc for it.

Main concepts:

This section is pretty much just a placeholder.

  • Application: A global container for all application data. Is also a Router itself (aka: main application router).
  • VirtualPath: An extended path that can contain variables, options and aliases.
  • Router: An object that contains Routes and is mounted to a VirtualPath. You can have as many as you want.
  • Route: An object created by a Router and mounted onto it.
  • StatusEvent: An event that is triggered when certain HTTP statuses are encountered.
  • Request: A predefined object that contains information about the requested resource.
  • Response: A predefined object that contains information about the response to be sent.
  • Handler: A user defined callable that accepts Request and Response as parameters. It can be assigned to a Route or a StatusEvent.

Example code:

This code creates a Route that will listen for a request using HTTP method GET.

$app = Sonet\Application::getApp();

$app->get('hello|h/?name', function ($req, $res) {
	$name = $req->params->name ?? 'world';
	$res->html("Hello, $name!");
});

$app->run();

This VirtualPath corresponds to:

  • /hello
  • /hello/([^/]+)
  • /h
  • /h/([^/]+)

For example,

  • /hello will generate "Hello, world!"
  • /h/Einstein will generate "Hello, Einstein!"