Download the PHP package timfennis/apply without Composer

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

Apply

codecov Build Status

Apply is a PHP Library that aims to promote and bring functional programming ideas from different languages and libraries such as Haskell, Scala, Kotlin, Arrow and Cats to PHP.

Stability

The library is currently very much a work in progress. Everything could change at any moment.

Contributing

I'm currently looking for ideas, suggestions, criticisms and contributions. The library is very much in a draft state, some functions probably don't work they way they 'should' and test coverage is still only 50ish percent.

Curried Functions

Collections

All collection functions in this library attempt to follow a pattern in terms of naming and argument order. Usually the names and arguments you'll find are taken from Haskell's standard library. Every function has a Curried version where the argument order matches the one in Haskell. In this argument order the subject of the function is always the last argument so that the curried functions can be used to create partially applied functions that can be chained together in different ways. All of these functions also have imperative counterparts that are easier to use and read in some situations. These functions have the same argument order except that the subject is now the first argument followed by the other arguments in the same order. This order is chosen because it's easier to read in imperative code and because it's similar to most other languages.

Functions that return collections of elements will always return Generators in order to be as lazy as possible. Functions that return a single element, or a scalar value are not lazy.

All

Any

Returns true if any (or some) of the predicates are true.

identity and constant

These two guys can often be very useful in many situations. constant returns a function that always returns the value that you passed to it. While identity is a function that always returns it's argument.

Monads

Check this page for a good tutorial on what Monads are. You don't really have to understand them in order to (ab)use them though.

Try

Attempt represents the result of a computation that can either have a result when the computation was successful, or an exception if something went wrong. If the computation went correctly you get a Success<A> containing the result and if the computation goes wrong you get a Failure containing the exception.

Attempt looks a lot like Either but is especially useful in situations where you have to consume some library or language feature that throws unwanted exception. Attempt can be used to capture exceptions and performing computations on the result without having to build complicated and verbose try-catch blocks.

Most often you may want to fold over the computation

Option (Maybe)

The Option monad is a modern rewrite of schmittjoh/php-option which can be found here. It's designed to be mostly compatible with its interface.

Suggestions are welcome.

Either

Instead of using string as type directly you probably want to define your own error types like RequestError and ResponseError. Those types could then have meaningful properties that assist with error handling.

EvalM

Wrapper around a lazy computation.

Monad Comprehensions

Many programming languages have a form of monad comprehensions, but they go by different names with slightly different implementations. In Haskell, you have the 'do notation', in Scala you have for-comprehensions and in JavaScript you can use async/await to accomplish similar results.

In PHP, we don't have much use for asynchronous programming and IO monads, but the syntax of monad comprehensions can still offer us a way to combine the results of many monads elegantly.

First let's look at one example that doesn't look very nice. Here we have two computations that can fail in some way. In order to combine the results of these computations whe have to take them out of the 'package' that they came in, combine the results and wrap them back up. Your code may look something like this.

Now this is already pretty terrible but imagine you want to combine the result of 3 or even 10 options, welcome in callback hell.

The solution:

That looks a lot more like the kind of code that you want to write! It's not perfect because we have to wrap the whole thing in a callable and pass that to the binding function, but it's much easier to read then our first example. Especially if the amount of computations increases.

License

Most of the source code in this project is licensed under MIT. The Apply\Option packages is derived from schmittjoh/php-option which is licensed under Apache-2.0.

SPDX-License-Identifier: Apache-2.0 AND MIT


All versions of apply with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-mbstring Version *
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 timfennis/apply contains the following files

Loading the files please wait ....