Download the PHP package claytron5000/better-arrays without Composer

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

Better Arrays

This is a project of spite. It originated when I was tasked with fixing a reporting screen in a web application. The previous developer had done some gnarly repetitive database queries. As the application grew, this page got slower and slower until it started timing out. I knew I could get the data I needed in one query, but I would need to do some significant data reducing and mapping to get it to a state where it would fit into the expected charts and graphs.

Php has an amazing set of array methods; check them out if you haven't: https://www.php.net/manual/en/ref.array.php. As someone coming from ES6 JavaScript however, this appears to be a bit overwhelming. In ES6, most array handling can be done with "the big three": map, filter, reduce. Not only that, but you can chain the methods and make beautiful ropey array parsing chains.

In php you might find a method that fits your exact needs, there are 81 methods in that list. However, methods have different signatures, some are editing the array in place, and most importantly, they don't chain.

So in php you might have to do something like this:

You can see I lost interest about halfway through writing that. Also, notice how the method signature of array_map flips from array_reduce and array_filter.

I will admit the php array methods are powerful, but I assert they are overpowered, and as a result, hard to read, hard to write, and generally not user friendly.

I'm eliding one of php major features, keyed arrays. Some methods are included here, but we miss some of the functionality because of the one return policy.

In Better Arrays my goal is to make array handling chainable, easy to read, and easy to write. Most important to me are map, filter, and reduce, but there are too many juicy methods, so I included them where it makes sense. Because of the requirement this be chainable, I'm excluding any methods that modify the array in place.

Try it today, have a BetterArray.

Usage

If it's not obvious, this is a very personal project, and I haven't landed on a prefered implementation method yet, so I've inlcuded them all.

The BetterArray holding your array returns itself until you use one of the return methods. The primary one is returnArray, which returns the array in it's last state.


All versions of better-arrays with dependencies

PHP Build Version
Package Version
Requires php Version ^7.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 claytron5000/better-arrays contains the following files

Loading the files please wait ....