Download the PHP package nilportugues/eloquent-mongodb-repository without Composer

On this page you can find all versions of the php package nilportugues/eloquent-mongodb-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 eloquent-mongodb-repository

Eloquent MongoDB Repository

PHP7 Tested Build Status Scrutinizer Code Quality SensioLabsInsight Latest Stable Version Total Downloads License Donate

Eloquent MongoDB Repository using nilportugues/repository as foundation, using jenssegers/mongodb.

Installation

Use Composer to install the package:

Why? Drivers and Multiple Implementations!

Using this implementation you can switch it out to test your code without setting up databases.

Doesn't sound handy? Let's think of yet another use case you'll love using this. Functional tests and Unitary tests.

No database connection will be needed, nor fakes. Using an InMemoryRepository or FileSystemRepository implementation will make those a breeze to code. And once the tests finish, all data may be destroyed with no worries at all.

Available drivers:

Also, if you feel like changing the repository implementation, no logic changes would be needed, as there are a set of drivers for you to use out of the box:

Usage

To set up Eloquent you don't need Laravel or Lumen frameworks at all. This is how you use Eloquent in any project.

Now that Eloquent is running, we can use the Repository.

A note about MongoDB Models

The best way to ensure maximum compatibility with other Repository implementations is to ignore the MongoDB's ObjectId field: _id and declare one such as id. This means, not using MongoDB's ObjectId to fetch elements.

This also means that you'll need an Adapter build from MongoDB object the expected Business objects. More on that further down, or check the /example directory.

One Repository for One Eloquent Model

A well defined repository returns one kind of objects that belong to one Business model.

To be faithful to the repository pattern, using Eloquent Models internally is OK, but Business objects should be returned.

Therefore, you should translate Eloquent to Business representations and the other way round. This is represented by $userAdapter in the example below.

The fully implementation should be along the lines:

A sample implementation can be found in the /example directory.

One EloquentRepository for All Eloquent Models

While this is not the recommended way, as a repository should only return one kind of Business objects, this works well with Laravel projects.

While the amount of code is less than the previous example, bare in mind that your code will be coupled with Eloquent.

Filtering data

Filtering is as simple as using the Filter object. For instance, lets retrieve how many users are named Ken.

Notice how the key name matches the database column name in the users table.

Available options

Filter allow you to use must(), mustNot() and should() methods to set up a fine-grained search. These provide a fluent interface with the following methods available:

Sorting data

Sorting is straight forward. Create an instance of Sort and pass in the column names and ordering.

Fields data

Create a Fields object to fetch only selected columns. If no Fields object is passed, all columns are selected by default.

Fetching data

Repository allows you to fetch data from the database by using the following methods:

Quality

To run the PHPUnit tests at the command line, go to the tests directory and issue phpunit.

This library attempts to comply with PSR-1, PSR-2, PSR-4.

If you notice compliance oversights, please send a patch via Pull Request.

Contribute

Contributions to the package are always welcome!

Support

Get in touch with me using one of the following means:

Authors

License

The code base is licensed under the MIT license.


All versions of eloquent-mongodb-repository with dependencies

PHP Build Version
Package Version
Requires nilportugues/repository Version ^2.2
nilportugues/assert Version ^1.0
illuminate/database Version ^5.2
illuminate/pagination Version ^5.2
jenssegers/mongodb Version v3.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 nilportugues/eloquent-mongodb-repository contains the following files

Loading the files please wait ....