Download the PHP package paulhenri-l/eloquent-builder-decorator without Composer

On this page you can find all versions of the php package paulhenri-l/eloquent-builder-decorator. 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 eloquent-builder-decorator

Eloquent Builder Decorator

Build Status

This package will allow you to create Query builder decorators.

Why decorating the query builder?

Decorating a query builder might be useful if you are creating a package that accepts a query builder as an argument and want to call the same complex query on it at multiple places.

It is also useful if you want to share common queries between multiple projects.

Why using this package instead of the query builder macro system?

While being very useful the macro system is global.

If your package adds macros to the query builder, then, your code is having a side effect on the application of your user.

There are cases where this might be wanted, but if it is not, decorating is a safer approach.

Installation

Usage

Creating a decorator

In order to create a decorator you need to create a new class and make it extend PaulhenriL\EloquentBuilderDecorator\AbstractBuilderDecorator.

Inside of this class is the queryToDecorate property. This property contains the builder instance that you are decorating.

Using a decorator

Now that you have created your decorator you can use it like so:

Chaining multiple decorators

Decorators become really powerful when you chain them together. In this example we'll chain the fictional decorators QueryWithDates and QueryWithRegion.

Now that they are chained our query is extended with the methods of each one of them.

We can call their methods as many times as we want and in any order.

Caveats

If you want to keep the ability to chain decorators you have to make sure that the methods you create in your decorators are returning decorator instances and not builder instances.

So you should do:

and you shouldn't do:

The static::decorate($query) method is just a bit of syntactic sugar what it really does is new static($query).

Contributing

If you have any questions about how to use this library feel free to open an issue.

If you think that the documentation or the code could be improved in any way open a PR and I'll happily review it!


All versions of eloquent-builder-decorator with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3
illuminate/database Version ^8.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 paulhenri-l/eloquent-builder-decorator contains the following files

Loading the files please wait ....