Download the PHP package marcosh/lamphpda without Composer

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

lamPHPda

A collection of type-safe functional data structures

Aim

The aim of this library is to provide a collection of functional data structures in the most type safe way currently possible within the PHP ecosystem, still providing a generic and consistent API.

Main ideas

The two ideas which differentiate this from other functional libraries in PHP are:

Installation

Tools

We use Psalm as a type checker. It basically works as a compilation step, ensuring that all the types are aligned.

To benefit from this library, it is compulsory that your code runs through a Psalm check.

Development

This library includes a flake.nix file, enabling you to access a development environment equipped with PHP 8.1 and Composer. To utilize it, simply execute nix develop within the directory. For those using direnv (with nix-direnv), a preconfigured .envrc file is also provided, which will automatically load the environment upon entering the library directory.

Decision record

The relevant decisions regarding the project are collected in the adr folder, following the Architectural decision record format

Content

The library provides several immutable data structures useful to write applications in a functional style.

Currently, the implemented data structures are:

You can find more details about the implementation and the idea behind each data structure in the docs/data-structures folder.

How to interact with the data structures

The library is built to be extremely abstract and generic to allow extreme composability and reusability.

There are various ways which you can use to interact with the provided data structures.

Typeclasses

You can think of typeclasses as of behaviours which could be attached to a data structure. Since a data structure could in principle have more than one way to implement a specific behaviour (e.g., there's more than one way to use two integers to compute a new integer), we can not use directly interfaces to be implemented by our data structures. Therefore, typeclass instances are implemented as separate independent objects implementing an interface which describes the typeclass itself.

For example, the Semigroup typeclass, which describes the behaviour of putting together two things of the same type to obtain a thing of the same type, could be implemented as

Now we can implement a Semigroup instance for any type we want, even for native types. For example, we could implement a semigroup for addition between integers

Then we could use it to sum two integers

This specific instance is not that interesting, but the fact that you could write code which depends on a generic Semigroup definitely is!

The typeclasses we are currently exposing are:

More details on each typeclass can be found in the docs/typeclasses folder.

Typeclasses and data structures

As a design principle for this library, we try to expose on our data structures only methods which come from a typeclass. This means that the provided data structure have a standard common API which makes use of typeclasses instances.

For example, Either has two Apply instances. To choose which one you want to use, Either exposes the iapply method which takes as first argument an instance of an Apply typeclass for Either.

We are able to specify that a typeclass instance refers to a specific data structure using the so-called Brands, which are nothing else that tags at the type level which enable us to simulate higher kinded types.

Default typeclass instances

More often than not a data structure admits only one instance of a typeclass, or there exists one which is considered standard in the literature. In such cases it is quite inconvenient to sustain the burden of passing the typeclass instance; to ease the pain, we expose also the method where the default typeclass instance is already provided.

Continuing with the example in the previous section, Either exposes also a method apply where the EitherApply instance is hardcoded.

Contributing

If you wish to contribute to the project, please read the CONTRIBUTING notes.


All versions of lamphpda with dependencies

PHP Build Version
Package Version
Requires php Version >= 8.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 marcosh/lamphpda contains the following files

Loading the files please wait ....