Download the PHP package x-laravel/followable without Composer

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

Followable for Laravel

Tests Latest Stable Version PHP Version Total Downloads License

Polymorphic follows for Eloquent. Any model can be followed and any model can follow, so users can follow venues, artists or each other, and pages can follow too. Models that need approval, such as private accounts, receive follow requests they accept or reject.

Requirements

Package version PHP Laravel
1.x 8.4+ 13

Installation

Publish the config to change the defaults:

Preparing the Models

Implement CanFollow and use Follower on the model that follows. Implement HasFollowers and use Followable on every model that can be followed; only those models are accepted. A model can use both:

Implement RequiresFollowApproval on followable models that decide whether a new follow waits for approval. Models without it are followed at once.

The follower_id and followable_id columns follow Laravel's morph key type, so set Schema::defaultMorphKeyType('uuid') or 'ulid' before migrating if your models use them. If the followed models mix key types, such as integer and ULID keys, publish the migration and make followable_id a string column.

Configuration

Key Default Meaning
follower_model null Model followers(), followRequests() and mutualFollowers() return when called without one; null uses the users auth provider's model
connection null Connection of the follow table
follow.table 'follows' Name of the follow table
follow.model Follow::class Follow model; must extend the package's
prune.enabled true Schedule the pruning of left-behind follows
prune.schedule 'daily' A cron expression, or a frequency method with its arguments: 'dailyAt:03:30', 'twiceDaily:1,13', 'weeklyOn:1,04:00'
prune.chunk 1000 Rows deleted by each pruning query

Following

A model cannot follow itself. Following again keeps the existing follow as it is, so a pending request stays pending.

Follow Requests

When the followed model's requiresFollowApproval() returns true, follow() creates a pending request instead:

Requests are addressed by the follower, so the follow row itself never has to appear in a URL. The Follow model also offers accept(), reject(), isAccepted(), isPending() and the accepted() and pending() scopes.

Listing

Show counts and the follow state of a whole list in one query:

Mutual Follows

For models that both follow and are followed:

Deleting and Pruning

When a followed model or a follower is deleted, its follows and requests are deleted with it. Soft-deleted models keep them until they are force deleted.

Deletes that skip model events, such as bulk queries, database cascades or raw SQL, leave follows behind. The package schedules model:prune, daily by default, to remove follows whose followed model or follower no longer exists. Run it by hand with:

Pruning skips types that no longer resolve to a model and models on another connection.

Reacting to Follows

Every event carries the Follow and is dispatched after the surrounding transaction commits:

Event Dispatched when
Followed A follow takes effect at once
FollowRequested A follow waits for approval
FollowRequestAccepted A pending request is accepted; Followed is not dispatched again
FollowRequestRejected The followed model rejects a pending request
FollowRequestCancelled The follower withdraws a pending request
Unfollowed An accepted follow is removed by either side

Following a model that is already followed dispatches nothing. Follows removed together with their model or follower, or by pruning, dispatch nothing.

Testing

License

Open source software licensed under the MIT license.


All versions of followable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
illuminate/console Version ^13.0
illuminate/contracts Version ^13.0
illuminate/database Version ^13.0
illuminate/support Version ^13.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 x-laravel/followable contains the following files

Loading the files please wait ...