Download the PHP package alex-unruh/repository without Composer

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

Alex Unruh - Repository

This is an abstraction layer that extends Doctrine DBAL Query Builder with methods to help and reduce the amount of code for bind values, for example.

Installation:

Usage:

Let's see below a scenario with an insert query using only the Doctrine DBAL QueryBuilder:

Now let's see the same query with a bit of abstraction using Repository::class

Behind the scenes, the repository class executes exactly the same procedure, making the binds safely and returning the same result. If you has a big table, this can be very useful. In fact, all the methods present in Doctrine DBAL Query Builder be present in Repository::class because, as we already said, it extends DBAL QB. You're free to use as you want.

Methods that don't exist in the parent class (Doctrine DBAL QueryBuilder)

setConnection( array $connection_params ): Repository

If you need to use the same coonection in multiple queries, like a transaction, this is very useful:

get()

Used in final of a select statement to return a multidimensional array

getFirst()

Used in final of a select statement to return only the first result of a query

addValues( array $array_data )

setValues( array $array_data )

execute()

The execute method is responsible to make the safely bind params in insert, update and delete statements and return as the result the number of rows affected. It calls the setParameters() and executeStatement() methods by Doctrine DBAL parent class.

Although it is not visible, there will be a bindParam between the setValues and execute methods

setTypes( array $types ) : Repository

In some cases, when you work with Doctrine DBAL or other Query Builders, is necessary to set a data type of a specific column data. If you are store a cripted data in a table, for example, maybe was necessary to tell to Query Builder whats the type of this data because each type of database stores this differently.

In other cases, for security, you need to set the type of a value before stores him in your table, in setParameter method. If the type is different from the defined, an Exception will be thrown.

Lets see an example with Doctrine DBAL QueryBuilder:

Now, let's see with Repository::class

Extending the Repository::class:

Most queries can be performed using methods from the parent Repository class. But in some cases you may have more complex queries (like queries containing subqueries), which would "bloat" your controllers and you would like to put these queries in a separate class, using a repository pattern. For that you can create your own class and extend the repository parent class.

All classes that extends the Repositor::class needs to have at least the protected $table_name property to use the special crud methods that will be described below.

Another parameter that can be implemented in an inheritor class is $data_types which contains the data types described in the setTypes method above.

Don't waste time trying to understand the method below. While it works, it's just here to demonstrate a Repository pattern use case.

Methods available to be used only in extended classes: read, create, modify and remove.

All the methods described bellow neede to be used in clases that extends the Repositor::class because they use parameters defined in this classes, as $table_name or $data_types, for example.

read( array $data, string $table_alias = null ): Repository

create(array $data): Repository

Behind the scenes, repository::class wiil make the safely bind values using the $data_types array to each column if it be present on class properties.

modify( array $data, string $table_alias = null ): Repository

Behind the scenes, repository::class wiil make the safely bind values using the $data_types array to each column if it be present on class properties. Always use with where clauses

destroy( string $table_alias = null ): Repository

addParameter(string $key, string $val, string $type = null): Repository

This method is recomended to be used when you use the method modify and you need to add new parameters to bind in other clauses (like where clauses).

Enjoy.


All versions of repository with dependencies

PHP Build Version
Package Version
Requires doctrine/dbal Version ^3.3
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 alex-unruh/repository contains the following files

Loading the files please wait ....