Download the PHP package rentalhost/vanilla-array-query without Composer

On this page you can find all versions of the php package rentalhost/vanilla-array-query. 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 vanilla-array-query

ArrayQuery

A simple way to extract values from an array.

Real world: sometimes you need to work with an array with a lot of unnecessary information within a context, and it can be a problem. The ArrayQuery package can help simplify the return in a simple way, even with a multidimensional array.

Installation

With Composer

Usage

Simple extraction

As in the example above, you can extract information easily just by specifying the keys you want to extract from the source array.

Let's assume that we have an array containing information about a page, but we want to extract only its route and title, while all other information is irrelevant at the moment.

The output will capture from the first argument (the source array) only the keys indicated by the second argument (the query array), in the order in which it is requested.

Bidimensional extraction

It is also possible to extract information from bidimensional array in a simple way.

In this case, the query key will represent the key to be extracted from the source, and its value in array will represent the keys to be extracted from the second dimension.

So, let's assume that we have a bidimensional array containing information about a page, and we want to extract only some information related to it, keeping the original structure of the source array.

Multidimensional extraction

And going even further, we can extract information from an array even in a multidimensional source.

In this case, we pass a query containing an array of arrays, and in its keys we indicate what information we want to extract.

So, supposing that we have an array containing various information from several pages, but we are only interested in obtaining its routes, and nothing more.

Customized extraction

In some cases, the source array is too complex in a multidimensional way, and sometimes you need to simplify the output for something easier to work with.

For example, let's say you have a page, and the only thing that interests you is the title. But the title is inside the key header with a lot of information that you don't need in context.

In this case, you can enter a custom key that has a function as a value. This function will receive all the information existing at that level, and its return will be the output to that new key.

In the example below, note that the source array does not have a title key, but we will create it on-the-fly from the existing value inside the title key that is inside the header key.

This functionality will also allow you to transform an existing key, filtering its elements, for example.

Let's assume, then, that we have a page with a simplified route, but we want to make it absolute. The key will be kept as a route, but its value will change.

It is important to remember that the callable will receive the entire array of that context (the $page, in this case), and not the value of the key you are reassigning.

Advanced extraction

Finally, it is possible to perform an advanced extraction of values, creating keys on-the-fly through a callable as a value, but without a key.

The callable must return an array, where the keys that will be applied to the source array.

Let's assume, then, that we have several pages, and we want to use the own route as the key and the title as value.


All versions of vanilla-array-query with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
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 rentalhost/vanilla-array-query contains the following files

Loading the files please wait ....