Coder Social home page Coder Social logo

putchi / state-keepers Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 18 KB

State keepers for Laravel application

License: MIT License

PHP 100.00%
laravel state transactions gurd keeper laravel-state-keepers laravel-state-keeper laravel-db-transactions db-transactions

state-keepers's Introduction

state-keepers

State keepers for Laravel application

Any exception caught inside the closure will be handled and if necessary will rollback to previous app state so that no partial data will be stored on your Database.

Prerequisites

This package is an extension to Laravel and will work only on laravel 5.7 and up-words

Installing

Clone or Download this repo or install it by using composer bellow:

composer require putchi/state-keepers

You may publish project files (config, assets, translations, etc...) into your own project by running the bellow command:

php artisan vendor:publish --provider="StateKeepersServiceProvider"

Also you may need to clear config cache by running the following command:

php artisan config:cache

If you have trouble installing this package please view the list of issues here or open a new one.

Example of usage

return StateManager::guard(function () {
  // Call some function in some model...
  // #  e.g: return Model::someFunction($arg1, $arg2);
  // Side note: don't forget to use whatever parameters you want in the declaration of the anonymous function (above)...
  // #  e.g: function () use ($arg1, $arg2) {...}
}, function (\Throwable $exception) {
  // HERE WE CATCH THE ERROR (IF THERE WAS ONE)
  // you can use the $exception to show the error massage like: $exception->getMessage();
  // Or you can implement your own customized catch callback in here.
});

Contributing

You may fork this repo or suggest new features (or new keepers) via pull requests and by following our code of conduct guide bellow.

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Watch this project for changes, status or version updates.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Alex Rabinovich - Initial work - Putchi

See also the list of contributors who participated in this project.

If you liked our work we did here please give us the thumbs up by staring this repo.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

state-keepers's People

Contributors

putchi avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.