Download the PHP package decodelabs/greenleaf without Composer

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

Greenleaf

PHP from Packagist Latest Version Total Downloads GitHub Workflow Status PHPStan License

Super-fast directory based HTTP router

Greenleaf provides a fast and flexible way to route HTTP requests to your actions and pages.


Installation

Install via Composer:

Usage

The main entry point to use Greenleaf is a PSR-15 middleware that can be used with any PSR-15 compatible framework, such as Harvest. It will parse the request and attempt to match it against a set of configured routes.

The system is comprised of a set of generators that can scan and find available routes, a collection of flexible route types and an extensible dispatcher architecture that allows for different matching strategies.

Dispatcher

While the dispatcher is usually accessed through middleware, you can if needed instantiate the Dispatcher directly and treat it as a standard PSR HTTP Handler.

Namespace

The router will use Archetype to resolve Action classes from the URL - you can use Archetype's namespace mapping functionality to mount a directory for Http related classes:

If your app is based on the Fabric framework, this mapping is taken care of for you automatically, based on the app namespace in your config.

Generators

Generators are used to load and configure routes. The Generator interface defines a simple mechanism for implementations to find and load routes.

By default, Greenleaf will load a Scanner Generator which in turn will scan the directory tree for other Generators and load the Actions they provide.

To define Routes in your directory tree, you can start with a generic Routes Generator which expects routes to be defined by hand:

Router

When the Dispatcher runs, it loads an appropriate Router to take care of matching the request to the configured routes.

As of the current release, Greenleaf uses a generated switch based PatternSwitch Router that is extremely fast and efficient. There is also a CheckEach Router that runs a brute force loop over each route in turn - this is a very stable and predictable model, but is not recommended for production use.

When a Router implementation finds a match, it transforms the route pattern into a custom "leaf URL" in the format leaf:/path/to/file?query#fragment and a set of parameters that are then passed to the target of the route.

This is one of Greenleaf's biggest strengths as both input and output forms resolve to URL formats that can be easily looked up and matched against, both when matching in and when generating out.

Leaf URL

The URL format is mostly just a subset of HTTP URLs, with leaf as the scheme, standard path, query and fragment components.

For example:

Routes

There are currently three types of route available in Greenleaf:

Action

Actions need to implement an execute(DecodeLabs\Greenleaf\Request $request) method, and return a Response. Greenleaf provides a number of traits that can be used to add additional functionality and simplify writing logic for your views.

The ByMethodTrait for example will attempt to invoke a method on the Action based on the HTTP method of the request.

Note that most traits that work in this fashion will use Slingshot to invoke the method with deep dependency injection support. In this example, the slug from the matched route request URL is passed as a string to the action handlers.

Actions don't necessarily need to return PSR-7 responses directly - Greenleaf uses Harvest's response transformation system to convert all types of content responses to full PSR-7 HTTP responses.

Page

A page route is usually resolved to a content file or other type of component. Greenleaf provides a basic HTML file adapter that will load a file from the filesystem and return it as a response, however other packages provide more complex implementations, such as Horizon Page and Fragment component structures.

When a page route is matched, the file path is resolved using Monarch's path alias system, from a base path of @pages. This alias if not defined by your app, defaults to the @run/src/components/pages directory.

HTTP URLs

One of the main benefits of Greenleaf is that it allows you to generate URLs for your routes in a simple and flexible way by creating leaf URLs with many of the required URL constructs already in place.

The router will then be able to match these URLs to the correct route and pass the parameters to the HTTP URL generator.

Licensing

Greenleaf is licensed under the MIT License. See LICENSE for the full license text.


All versions of greenleaf with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
decodelabs/atlas Version ^0.12.4
decodelabs/archetype Version ^0.3.8
decodelabs/coercion Version ^0.3
decodelabs/dictum Version ^0.6.9
decodelabs/exceptional Version ^0.5.3
decodelabs/glitch-support Version ^0.5.1
decodelabs/harvest Version ^0.5
decodelabs/iota Version ^0.2.1
decodelabs/monarch Version ^0.1.1
decodelabs/singularity Version ^0.3
decodelabs/slingshot Version ^0.2
decodelabs/veneer Version ^0.12.3
psr/container Version ^2.0.2
psr/http-message Version ^2.0
psr/http-server-handler Version ^1.0.2
psr/http-server-middleware Version ^1.0.2
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 decodelabs/greenleaf contains the following files

Loading the files please wait ....