Download the PHP package ray/media-query without Composer

On this page you can find all versions of the php package ray/media-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 media-query

Ray.MediaQuery

Media access mapping framework

codecov Type Coverage Continuous Integration

日本語 (Japanese)

Overview

Ray.QueryModule makes a query to an external media such as a database or Web API with a function object to be injected.

Motivation

Composer install

$ composer require ray/media-query

Getting Started

Define the interface for media access.

DB

Specify the SQL ID with the attribute DbQuery.

Web API

Specify the Web request ID with the attribute WebQuery.

Create the web api path list file as web_query.json.

Module

MediaQueryModule binds the execution of SQL and Web API requests to an interface by setting DbQueryConfig or WebQueryConfig or both.

Note: MediaQueryModule requires AuraSqlModule to be installed.

Request object injection

You do not need to prepare an implementation class. It is generated and injected from the interface.

DbQuery

When the method is called, the SQL specified by the ID is bound with the method argument and executed. For example, if the ID is todo_item, the todo_item.sql SQL statement is bound with ['id => $id] and executed.

Entity

When the return value of a method is an entity class, the result of the SQL execution is hydrated.

Use CameCaseTrait to convert a property to camelCase.

If the entity has a constructor, the constructor will be called with the fetched data.

Entity factory

To create an entity with a factory class, specify the factory class in the factory attribute.

The factory method of the factory class is called with the fetched data. You can also change the entity depending on the data.

If the factory method is not static, the factory class dependency resolution is performed.

Web API

Parameters

DateTime

You can pass a value object as a parameter. For example, you can specify a DateTimeInterface object like this.

The value will be converted to a date formatted string at SQL execution time or Web API request time.

If no value is passed, the bound current time will be injected. This eliminates the need to hard-code NOW() inside SQL and pass the current time every time.

Test clock

When testing, you can also use a single time binding for the DateTimeInterface, as shown below.

VO

If a value object other than DateTime is passed, the return value of the toScalar() method that implements the ToScalar interface or the __toString() method will be the argument.

Parameter Injection

Note that the default value of null for the value object argument is never used in SQL. If no value is passed, the scalar value of the value object injected with the parameter type will be used instead of null.

`

Pagenation

The #[Pager] annotation allows paging of SELECT queries.

You can get the number of pages with count(), and you can get the page object with array access by page number. Pages is a SQL lazy execution object.

The number of items per page is specified by perPage, but for dynamic values, specify a string with the name of the argument representing the number of pages as follows

Use @return to specify hydration to the entity class.

SqlQuery

SqlQuery executes SQL by specifying the ID of the SQL file. It is used when detailed implementations with an implementation class.

Get* Method

To get the SELECT result, use get* method depending on the result you want to get.

Ray.MediaQuery contains the Ray.AuraSqlModule. If you need more lower layer operations, you can use Aura.Sql's Query Builder or Aura.Sql which extends PDO. doctrine/dbal is also available.

Profiler

Media accesses are logged by a logger. By default, a memory logger is bound to be used for testing.

Implement your own MediaQueryLoggerInterface and run You can also implement your own MediaQueryLoggerInterface to benchmark each media query and log it with the injected PSR logger.

Annotations / Attributes

You can use either doctrine annotations or PHP8 attributes can both be used. The next two are the same.

Testing Ray.MediaQuery

Here's how to install Ray.MediaQuery from the source and run the unit tests and demos.


All versions of media-query with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-pdo Version *
ext-mbstring Version *
aura/sql Version ^4.0 || ^5.0
doctrine/annotations Version ^1.12 || ^2.0
guzzlehttp/guzzle Version ^6.3 || ^7.2
koriym/csv-entities Version ^1.0
koriym/null-object Version ^1.0.1
nikic/php-parser Version ^4.15 || ^5.0
pagerfanta/pagerfanta Version ^3.5
phpdocumentor/reflection-docblock Version ^5.3
phpdocumentor/type-resolver Version ^1.6.1
ray/aop Version ^2.10.4
ray/aura-sql-module Version ^1.12.0
ray/di Version ^2.14
roave/better-reflection Version ^4.12 || ^5.6 || ^6.25
symfony/polyfill-php81 Version ^1.24
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 ray/media-query contains the following files

Loading the files please wait ....