Download the PHP package phunkie/phunkie-adt without Composer

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

Phunkie ADTs: Algebraic Data Types for PHP

"In computer programming, especially functional programming and type theory, an algebraic data type is a kind of composite type, i.e., a type formed by combining other types." — good old Wikipedia

Sum Types

In computer science sum type, is a data structure used to hold a value that could take on several different, but fixed, types. Only one of the types can be in use at any one time, and a tag field explicitly indicates which one is in use.

Let's say we want to create a type Weekday. We want it to be limited to the possible 7 days in the week: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday and Saturday.

We could do that in a number of ways using typical imperative or Object Oriented techniques. We could use enums, constants grouped under an interface or inheritance.

At the moment PHP does not have enums, so that one is not a choice.

Grouping constants in a interface is a popular alternative, but it does not give any type safety.

When passing a weekday to a function I cannot specify the Weekday type as a type hint.

Finally we could try extending a super class or implementing a common interface.

Now we can type hint Weekday we passing it around:

There is, however, no way in PHP to guarantee that the interface won't be extended beyond the ones distributed with the library. Nothing stops a Pluto fan from:

And all of a sudden we can now order pizza in weird days. But fear not! Sum types is there to save us from that madness.

First we create a type constructor Weekday. PHP only way to create hintable types is through classes. So, let's use that.

Then we seal it. Let's use ImmutableSealed to add immutablity while we are at it

ImmutableSealed requires us to tell what is the types the type constructor can create

We still need to create the sum types:

If we try to extend Weekday outside the seal we get a type error.

TODO:

Final Notes


All versions of phunkie-adt with dependencies

PHP Build Version
Package Version
Requires kahlan/kahlan Version ^3.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 phunkie/phunkie-adt contains the following files

Loading the files please wait ....