Download the PHP package telkins/laravel-pending-action without Composer

On this page you can find all versions of the php package telkins/laravel-pending-action. 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 laravel-pending-action

A (somewhat opinionated) Laravel package to help make preparing and executing actions a little easier and more uniform.

Latest Version on Packagist Tests Quality Score Total Downloads

This package is inspired by a few people. Please check out the following to see where the inspiration came from:

From time to time you may need to perform tasks or actions in your application or different parts of your code where there isn't an out-of-the-box Laravel solution. Most likely, this is or is related to your business logic. An oft-used example is creating an invoice. This is an action that may need to take place in one of your applications. It will likely require parameters, and it will likely be made up of smaller actions.

The goal of this package is to provide a (somewhat opinionated) way to make, define, and use actions. You can create Action classes and then, when you want to execute that action, you "prep" that class: $myAction = MyAction::prep();. You get back a pending action object, which you define, that allows you to provide the parameters necessary for your action to be carried out. When ready, you call execute().

Here's an example...borrowing from Freek's video:

Installation

You can install the package via composer:

Usage

For now, one must manually create Action and PendingAction classes. A future release will include the ability to create Action and PendingAction classes via php artisan.

Create an Action

There are two main ways to create an action class, depending on your needs:

Create a "Light" Action

This method of creating an action requires the least amount of code. As such, you can call this a "light" action class. A class like this will work perfectly fine. But, because the prep() method's signature shows a PendingAction interface return type, your IDE will not know what object you're given and code completion will be limited when working with pending action objects. You may be able to provide information to your IDE in order to have full code completion for pending action objects, but that will require additional work.

Still, this may be perfectly fine for you. So, should you wish to create an action class like this, simply create a class that extends the abstract Action class like so, adding an execute() method that takes the pending action object:

Create an "IDE-Friendly" Action

This method of creating a small amount of additional code for each action class. This additional code, however, will play nicely with your IDE, allowing code completion, if available.

Should you wish to create an action class like this, simply create a "light" action class like above and then add a prep() method like so:

Note: The autoPrep() method handles pending action object preparation for you.

Pending Action Class Naming Conventions

By default, each Action class will look for a pending action class that has the same FQCN with PendingAction appended. So, for our example CreateSubscriber class, it will look for CreateSubscriberPendingAction.

To override this behavior, you can specify the pending action class name in your Action class like so:

Create a Pending Action

To create a pending action class, simply extend PendingAction like so, providing fluent methods to build up the pending action object that will then be used to execute the action:

"Prep" Your Action, Carry it Out

Once you have built your action and pending action classes, then you can begin to use them. There are three main steps to preparing your action and executing it:

  1. Call the static prep() method on your Action class. This returns the pending action object.
  2. Using the pending action object, provide the parameters needed for the action.
  3. Finally, call the execute() method on the pending action object.

Here is an example of preparing and executing an action all at once:

Here is an example of using the pending action object to provide different parameters to carry out the action for different scenarios:

Add a Pending Action Constructor to Improve "Prep"

Sometimes you may not want to litter your code with somewhat redundant or obvious method calls. For example, if you have an action class that is meant to update a leaderboard, then you may not want to have to specifically call a leaderboard() method. By creating a constructor on your pending action class, you can pass in the leaderboard via the action's prep() method.

Here is how your pending action class might look in order to take advantage of this feature:

You can then use it like so:

NOTE: This functionality is not IDE-friendly and the developer will be responsible for passing the right types of arguments in the right order to their constructor via prep().

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please use the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-pending-action with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4
laravel/framework Version ^6.0|^7.0|^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 telkins/laravel-pending-action contains the following files

Loading the files please wait ....