Download the PHP package mathsgod/light-server without Composer

On this page you can find all versions of the php package mathsgod/light-server. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package light-server

Light Server

Tests

A lightweight PHP 8.1+ web framework with file-based routing, PSR-7 support, and automatic dependency injection.

Requirements

Features

Installation

Quick Start

1. Create an entry point

The server supports both pages/ next to the entry point and the common project layout with public/index.php and pages/ at the project root.

2. Create a page handler

Routing

Routes are generated automatically from the pages/ directory structure:

File Route
pages/index.php /
pages/about.php /about
pages/blog/index.php /blog and /blog/
pages/blog/{id}/index.php /blog/{id} and /blog/{id}/

If the pages/ directory does not exist, the server starts normally with no routes.

Routes use a canonical path without a trailing slash, but both /blog and /blog/ dispatch to the same page handler. A page file and a directory index cannot define the same canonical route: pages/blog.php and pages/blog/index.php cause a startup route-collision error.

HTTP Methods

Define public methods matching the HTTP verb (case-insensitive):

HEAD requests use the head() method when defined; otherwise they reuse get() and return the response headers without a body. OPTIONS requests use the options() method when defined; otherwise routes return 204 No Content.

Dynamic Routes

Route parameters are available via $request->getAttribute():

Route Constraints

Since routing is powered by League\Route, you can constrain route parameters directly in the folder/file name using {param:type} syntax:

Constraint Pattern Example match
{id:number} [0-9]+ 123
{name:word} [a-zA-Z]+ raymond
{slug:slug} [a-z0-9-]+ my-post
{token:alphanum_dash} [a-zA-Z0-9-_]+ abc-123_x
{id:uuid} UUID format 550e8400-e29b-41d4-a716-446655440000
{path:any} .+ foo/bar/baz

Example: Only match when id is numeric and name is alphabetic:

Dependency Injection

Method parameters are resolved automatically by type hint:

Pass a PSR-11 container when creating the server:

Middleware

Global Middleware

Use pipe() to apply middleware to all routes:

Attribute-based Middleware (per method)

Attach PSR-15 middleware to a specific handler method using PHP attributes:

Built-in Middleware

CorsMiddleware

Handles CORS preflight (OPTIONS) requests and adds CORS headers to all responses.

All constructor parameters are optional:

Parameter Default Description
allowedOrigins ['*'] Allowed origins. Use ['*'] for wildcard
allowedMethods ['GET','POST','PUT','PATCH','DELETE','OPTIONS'] Allowed HTTP methods
allowedHeaders ['Content-Type','Authorization'] Allowed request headers
allowCredentials false Set true to send Access-Control-Allow-Credentials: true
maxAge 86400 Preflight cache duration in seconds

Note: When using allowCredentials: true, allowedOrigins must list specific origins — wildcard * does not work with credentials and raises an InvalidArgumentException.

SecurityHeadersMiddleware

Adds common security response headers:

Header Value
X-Content-Type-Options nosniff
X-Frame-Options DENY
X-XSS-Protection 1; mode=block
Referrer-Policy strict-origin-when-cross-origin
Content-Security-Policy default-src 'self'

Testing

The test suite runs against PHP 8.1, 8.2, 8.3, 8.4, and 8.5 via the GitHub Actions matrix in .github/workflows/tests.yml.

License

MIT — see the LICENSE file for details.


All versions of light-server with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
league/route Version ^6.0
laminas/laminas-diactoros Version ^3.5
laminas/laminas-httphandlerrunner Version ^2.11
laminas/laminas-stratigility Version ^4.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mathsgod/light-server contains the following files

Loading the files please wait ...