Download the PHP package alexandre-daubois/poq without Composer

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

POQ - PHP Object Query

Minimum PHP Version CI Latest Unstable Version License

Install

That's it, ready to go! 🎉

Usage

Here is the set of data we're going to use in the follow examples:

The ObjectQuery object

The ObjectQuery object allows you to easily fetch deep information in your collections with ease. Just like Doctrine's QueryBuilder, plenty of utils methods are present for easy manipulation.

Moreover, you're able to create your query step-by-step and conditionally if needed. To create a simple query, all you need to do is call ObjectQuery's from factory, and pass your collection as its source:

From here, you're able to manipulate your collections and fetch data. First, let's see how to filter your collections. Note that the city argument is optional and defines an alias for the current collection. By default, the alias is _. Each alias must be unique in the query, meaning it is mandatory you pass an alias if you are dealing with deep collections. Defining an alias allows you to reference to the object later in the query. See the selectMany operation explanation for more details.

Modifiers (filtering, ordering, limiting, etc.)

Modifiers allow to filter results, order them, limit them and so on.

🔀 Modifiers can be given to the query in any order, as they are only applied when an operation is called.

Where

Usage

where, which takes a callback as an argument. This callback must return a boolean value.

Order by

orderBy, which will order the collection. If the collection only contains scalar values, then you only have to pass an order. If your collection contains objects, you have to pass the order as well as the field to order on. Available orders are: QueryOrder::Ascending, QueryOrder::Descending, QueryOrder::None and QueryOrder::Shuffle.

Offset

offset modifier changes the position of the first element that will be retrieved from the collection. This is particularly useful when doing pagination, in conjunction with the limit modifier. The offset must be a positive integer, or null to remove any offset.

Limit

The limit modifier limit the number of results that will be used by different operations, such as select. The limit must be a positive integer, or null to remove any limit.

Operations

Operations allow you to fetch filtered data in a certain format. Here is a list of the available operations and how to use them.

Select

This is the most basic operation. It returns filtered data of the query. It is possible to pass the exact field we want to retrieve, as well as multiple fields. If no argument is passed to select, it will retrieve the whole object. You must not pass any argument when dealing with scalar collections.

Select One

When querying a collection, and we know in advance that only one result is going to match, this could be redundant to use select and retrieve result array's first element everytime. selectOne is designed exactly for this case. The behavior of this operation is the following:

Select Many

This operation allows you to go deeper in a collection. Let's say your collection contains many objects with collections inside them, this is what you're going to use to fetch and filter collections.

Note that we defined an alias for city, which allows to reference the parent city in the last where call.

Like from, selectMany also takes an alias as an argument. This way, you will be able to reference ancestors in your where calls, as shown in the above example.

Count

This operation returns the size of the current filtered collection:

Concat

This operation will concatenate the collection with a given separator. If you're dealing with a scalar collection, there is no mandatory argument. If dealing with collections of objects, the field argument must be passed.

Each

This operation allows you to pass a callback, which will be applied to each element of the filtered collection. You can see this as a foreach.

Min and Max

These operations will return the maximum and the minimum of the collection. You can use this on scalar collections. Internally, these operations use min() and max() functions of the Standard PHP Library, so the same rules apply.

Sum

sum returns the sum of a collection. If the collection contains objects, a field must be provided in order to calculate the sum of it. This only works with collections of numerics, and an exception is thrown if any item of the collection returns false to the \is_numeric() function.

Average

average returns the average of a collection. If the collection contains objects, a field must be provided in order to calculate the average of it. This only works with collections of numerics, and an exception is thrown if any item of the collection returns false to the \is_numeric() function.


All versions of poq with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
symfony/property-access Version ^6.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 alexandre-daubois/poq contains the following files

Loading the files please wait ....