Download the PHP package aurasidera/sextant without Composer

On this page you can find all versions of the php package aurasidera/sextant. 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 sextant

Sextant

Flexible and unopinionated PHP routing library.

Sextant allows to easily define routes without forcing users to adhere any specific convention, nor implementing over-complicated patterns. You declare a list of action): action of first route whose condition is satisfied will be performed.

A condition is anything callable which can return a boolean value. A bunch of ready-to-use condition models are available for you by default, but you will probably end up using the almighty Simple condition, which natively supports method and URL matching, and named parameters in URL.

An action is anything callable. Really, nothing fancy here. Sextant has ready-to-use action models already available, such as "show this string", "shows this JSON", "include this PHP script", etc..

You can define a default action to perform when no route matches (useful for custom 404 pages).

Installation

Sextant can be installed through Composer, although manual installation is available as well.

Requirements

php>= 7.0.0

Composer

Add aura/sextant to your composer.json file, or run:

composer require aura/sextant

Manual

Clone or download this repository:

or

File structure adheres to PSR-4: no big surprises when including files.

Examples

Basic usage: covers most use cases!

For most applications you will just need some mechanism to associate actions to URLs. That's great, and couldn't be simpler! You can just copy-paste this and ask no questions:

What's going on here?

Advanced usage

To get the most out of Sextant you need some knowledge about the system. Be sure to read (and understand) the Concepts section before proceeding.

Using default factories is cool, but sometimes you just need more flexibility. That's fine: you can still set default factories, but override them with specific ones for some routers. Suppose you are fine with the behavior of the ConditionFactory\Simple most of the time, but you want an action to be performed for a specific URL pattern regardless of condition: you can use the basic usage example and add:

And it goes similar for actions, suppose you want to show a JSON document:

Guess what? You can mix conditions and actions:

This becomes more verbose: that's the trade-off between being concise and being flexible.

Sextant provides some ready-to-use condition and action factories you can play around with. If you want to go even further, you can play around with meta conditions: they are special conditions which allows to build arbitrarily complex, boolean-based conditions. Take this purposely over-complicated condition:

What is this mess? That's a route which requires:

clearly that's not a realistic route, but you can see how any formula in Conjunctive Normal Form can be expressed by these mechanism. Sextant is therefore complete with respect to boolean algebra! Hurray!

TLDR: You can create custom complex boolean conditions on the fly without touching the code.

Nerd usage

Why should you? I see, you are that type of person...

You can define your own conditions and actions. Bear in my the following mantra:

condition: State => bool
action: State => nothing

When implementing custom actions or conditions, match those types and you will be fine. You can use functions, anonymous functions, closure or callable objects (implementing the __invoke magic method). Here's an example:

Pretty neat, isn't it?

Concepts

Main concepts in Sextant.

State

A state is an object representing current state of the request. State always includes:

all of which can be retrieved using the appropriate getter method. A state can be automatically read from server by using the helper static factory method getStateFromServer:

State can be decorated with named entities, which can be accessed both with member and array access syntax. Trying to read an undefined entity will return null:

Conditions

A condition is any callable which returns a boolean. Sextant will automatically pass a State testing a route. Sextant also offers a number of ready-to-use condition in the form of abstract factories, under the ConditionFactory namespace. Factories can be instantiated and used in routes as in the following example:

It is usually more convenient to use the following, equivalent, more concise and clearer syntax:

Note that, although Sextant uses classes to implement factories which produce conditions, this pattern is not mandatory. It is possible to use any type of function (including anonymous functions, closures and callable objects):

Actions

Actions are callable, without other particular requirements. They usually produce some type of output in the page, set some headers, manipulate a database, or a mix of those. Sextant will automatically inject the state when calling an action. Sextant has a number of ready-to-use actions, such as a default 404 page setting the appropriate header, a JSON renderer, a file rendered and a script executor. The ActionFactory contains such action factories. An action factory is an object building an action, which can be later used in a route:

The following equivalent and more concise syntax is preferred:

Sextant used classed to implement factories which produce actions, but this is not mandatory. Custom functions can be used as well:

Actions are allowed to change named entities associated to $state, but cannot modify URL, methods, parameters or headers.

Routes

A route is an association between a condition and an action. Routes are declared inside a router, which will eventually try to match them in a given context (URL, method, headers, etc.). First route whose condition is satisfied in the context will be chosen, and its action performed. Routes are tested in the same order they are declared.


All versions of sextant with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
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 aurasidera/sextant contains the following files

Loading the files please wait ....