Download the PHP package roberthucks/selfdestruct without Composer

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

Self Destruct

This package was built with the goal in mind of creating a repeatable way of having models delete themselves after a specified amount of time. Currently, the package is fairly basic but could be expanded upon to allow deeper customisation and the ability of having per-record expiration times rather than scoped to each model.

What's in the package

This can be used on Models to give it the ability to delete after a specified time.

Table that is used to manage the destruction of Models.

How it works

This package works by using the provided Trait on a Model which hooks in to the created event. When a Model is created, it takes the sum of created_at and life_time and stores it in a seperate table. Then, every minute this table is checked for expired records and each Model is deleted.

How to use

1) Adding the package to your project.

2) Run migration to create the table

3) Configure models

The first step here is to add the Trait to the Model. Add use RobertHucks\SelfDestruct\Traits\SelfDestruct; and then user it inside your Models class like so use SelfDestruct; Once these have been added to your Model you need to then add a property called $life_time. This is the amount of seconds that a Model should stay alive for.

Here is how a Model looks when modified:

4) Set up Laravel's scheduler

This package requires the use of the Task Scheduler. You should make sure that it is configured and running correctly on your system or else this package will do nothing.

Considerations

This package relies on having a created_at field on your Model. In this future this would be a configurable field or possibly even removed for just having the current time but for now, this is a requirement of the Model.

Another thing to keep in mind is that the Task for clearing expired Models runs every minute. This means that the deletion will almost never occur on the exact time of expiry. If there is another way to perform this action I am all ears but this wasn't an issue for my use-case and therefore was a limitation I was happy to accept.


All versions of selfdestruct with dependencies

PHP Build Version
Package Version
No informations.
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 roberthucks/selfdestruct contains the following files

Loading the files please wait ....