Download the PHP package loophp/repository-monadic-helper without Composer

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

Latest Stable Version GitHub stars Total Downloads GitHub Workflow Status Type Coverage License Donate!

Doctrine Repository Monadic Helper

Description

This project provides the necessary classes and services to use Doctrine repositories in a more functional way, by using monads.

This project also demonstrate that it's a nice and clean way to work with repositories and non-deterministic data store, in this case, a database.

There is no need to always check for the existence of an entity, so we are able to reduce the amount of conditions and cruft, while focusing on what's important and relevant only.

When using properly typed monads and callbacks, types inconsistencies will be instantly detected by static analysis tools. This provides a safer and better way to design functions and data transformation methods.

The monad in use in this project is the Either monad, provided by the contrib package Lamphpda from Marco Perone.

History

This project started as a proof-of-concept for my own needs and for many reasons.

I first wanted to get rid of all the checks and conditions that were needed in my code to test if an entity was existing or not.

Then, it turns out that this was a recurrent pattern that I was seeing the code of my friends, colleagues and issue queue.

A practical way to get rid of conditions is to use a more declarative way of programming and adopt a more functional programming style.

And lastly, willing to learn more about the monads which are some kind of "design patterns" for functional programming, I started to write this package.

This package does not have the pretention to become a de-facto standard on how to use Doctrine repositories, but it might help people understanding what monads are, how to use them, and hopefully reduce the amount of conditions in their code.

The monad package in use here is an arbitrary choice. I could have used some other packages, but marcosh/lamphpda seems to be the best option, especially when you analyse your code with static analysis tools to detect issues upfront, without running their unit tests.

Installation

Usage

To use this package and have monadic repositories, there are 3 options available:

In my own opinion, the best way to use this package is to use the first option.

It's paramount to replace EntityClassName with the entity class in use in the repository in order to let static analysis tools infer types properly.

For the option 2 and 3, let's use the following usual Doctrine repository as example:

Option 1: Using a service

Option 2: Using an interface and a trait on existing repositories

Upgrade your Doctrine repositories to:

Option 3: Replace ServiceEntityRepository with MonadicServiceEntityRepository

Upgrade your Doctrine repositories to:

API

The following methods will be available when using the service (option 1) or upgrading your repositories (options 2 and 3).

For each API methods, the placeholder MyCustomEntity should be replaced by the entity you're referring to.

eitherFind

Signature:

An exception is generated and wrapped in the monad when the returned result is null.

eitherFindAll

Signature:

An exception is generated and wrapped in the monad when the returned result is empty.

eitherFindBy

Signature:

An exception is generated and wrapped in the monad when the returned result is empty.

eitherFindOneBy

Signature:

An exception is generated and wrapped in the monad when the returned result is null.

Todo

Contributing

Feel free to contribute by sending pull requests. We are a usually very responsive team and we will help you going through your pull request from the beginning to the end.

For some reasons, if you can't contribute to the code and willing to help, sponsoring is a good, sound and safe way to show us some gratitude for the hours we invested in this package.

Sponsor me on Github and/or any of [the contributors][contributors].

Changelog

See [CHANGELOG.md][47] for a changelog based on git commits.

For more detailed changelogs, please check the release changelogs.

[phpsandbox image]: https://img.shields.io/badge/Try%20it-online%20!-brightgreen?style=flat-square

[44]: https://tomasvotruba.com/blog/2017/10/16/how-to-use-repository-with-doctrine-as-service-in-symfony/

[47]: https://github.com/loophp/repository-monadic-helper/blob/main/CHANGELOG.md

[50]: https://symfony.com/doc/current/service_container.html#binding-arguments-by-name-or-type

[contributors]: https://github.com/loophp/repository-monadic-helper/graphs/contributors


All versions of repository-monadic-helper with dependencies

PHP Build Version
Package Version
Requires php Version >= 8.1
marcosh/lamphpda Version ^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 loophp/repository-monadic-helper contains the following files

Loading the files please wait ....