Download the PHP package yiisoft/data without Composer

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

Yii

Yii Data


Latest Stable Version Total Downloads Build status Code Coverage Mutation testing badge static analysis type-coverage psalm-level

The package provides generic data abstractions. The aim is to hide a storage aspect from the operations of reading, writing and processing data.

Features are:

Requirements

Installation

The package could be installed with Composer:

General usage

Concepts

Reading data

Data reader aim is to read data from a storage such as database, array or API and convert it to a simple iterator of field => value items.

Result is iterable so you can use foreach on it. If you need an array, it could be achieved the following way:

Limiting the number of items to read

You can limit the number of items in an iterator:

Counting the total number of items

To know total number of items in a data reader implementing CountableDataInterface:

Filtering

Filtering of data could be done in two steps:

  1. Forming a criteria for getting the data. That is done by "filter."
  2. Post-filtering data by iteration and checking each item. That is done by IterableDataReader with filters.

Whenever possible, it is best to stick to using criteria because usually it gives much better performance.

To filter data in a data reader implementing FilterableDataInterface you need to supply filter to withFilter() method:

Filter could be composed with:

Filtering with arrays

The All and Any filters have a withCriteriaArray() method, which allows you to define filters with arrays.

Implementing your own filter

To have your own filter:

You can add your own filter handlers to the data reader using the withFilterHandlers() method. You can add any filter handler to the reader. If a reader is not able to use a filter, filter is ignored.

Sorting

To sort data in a data reader implementing SortableDataInterface you need to supply a sort object to withSort() method:

The goal of the Sort is to map logical fields sorting to real data set fields sorting and form a criteria for the data reader. Logical fields are the ones user operates with. Real fields are the ones actually present in a data set. Such a mapping helps when you need to sort by a single logical field that, in fact, consists of multiple fields in the underlying data set. For example, you provide a user with a username which consists of first name and last name fields in the actual data set.

To get a Sort instance, you can use either Sort::only() or Sort::any(). Sort::only() ignores user-specified order for logical fields that have no configuration. Sort::any() uses user-specified logical field name and order directly for fields that have no configuration.

Either way, you pass a config array that specifies which logical fields should be order-able and, optionally, details on how these should map to real fields order.

The current order to apply is specified via withOrder() where you supply an array with keys corresponding to logical field names and values correspond to order (asc or desc). Alternatively withOrderString() can be used. In this case, ordering is represented as a single string containing comma separate logical field names. If the name is prefixed by -, ordering direction is set to desc.

Skipping some items

In case you need to skip some items from the beginning of data reader implementing OffsetableDataInterface:

Implementing your own data reader

To have your own data reader, you need to implement at least DataReaderInteface. It has a single read() method that returns iterable representing a set of items.

Additional interfaces could be implemented to support different pagination types, ordering and filtering:

Note that when implementing these, methods, instead of modifying data, should only define criteria that is later used in read() to affect what data is returned.

Pagination

Pagination allows getting a limited subset of data that is both handy for displaying items page by page and for getting acceptable performance on big data sets.

There are two types of pagination provided: traditional offset pagination and keyset pagination.

Offset pagination

Offset pagination is a common pagination method that selects OFFSET + LIMIT items and then skips OFFSET items.

Advantages:

Disadvantages:

Usage is the following:

Keyset pagination

Keyset pagination is an alternative pagination method that is good for infinite scrolling and "load more." It is selecting LIMIT items that have key field greater or lesser (depending on the sorting) than the value specified.

Advantages:

Disadvantages:

Usage is the following:

When displaying first page ID (or another field name to paginate by) of the item displayed last is used with withNextPageToken() to get next page.

Writing data

Processing data

Documentation

If you need help or have a question, the Yii Forum is a good place for that. You may also check out other Yii Community Resources.

License

The Yii Data is free software. It is released under the terms of the BSD License. Please see LICENSE for more information.

Maintained by Yii Software.

Support the project

Open Collective

Follow updates

Official website Twitter Telegram Facebook Slack


All versions of data with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
yiisoft/arrays Version ^3.0
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 yiisoft/data contains the following files

Loading the files please wait ....