Download the PHP package newman/laravel-delay without Composer
On this page you can find all versions of the php package newman/laravel-delay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-delay
Laravel Delay
Package which helps you to delay (sleep) your code for some time.
Note before continuing
As of Laravel version 10.10.0 you may not need this package anymore in favour of in-built helper - https://laravel.com/docs/10.x/helpers#sleep
Installation
Requirements
- Laravel 8.12+, 9.0+, 10.0+
- PHP 8.0
Installation
Require the package via Composer:
:book: Usage
Using as Facade
Using as Trait
then in code you can call the delay the code execution like this:
or
They both will delay execution for 5 seconds.
You can include trait in any class you'd like to use it, including controllers.
Using as service container
Usage samples
Let's assume we're using Trait.
Delay execution for 10 seconds:
Note that in case you want to delay for fractions of a second, you should use forMs
function.
Delay execution for 1500 miliseconds (1.5 second):
Delay execution for 5000 microseconds (0.005 second):
Delay execution till given Carbon datetime:
Delay execution for 10 seconds only on given environment/-s:
Delay execution for 10 seconds except given environment/-s:
Delay execution for 10 seconds only when callback returns false:
and we can even pass multiple callbacks.
At last we can chain multiple conditions:
It will delay for 10 seconds only on production & staging environments and only when it's not 10 AM.
:handshake: Contributing
We'll appreciate your collaboration to this package.
When making pull requests, make sure:
- All tests are passing:
composer test
- Test coverage is not reduced:
composer test-coverage
- There are no PHPStan errors:
composer phpstan
- Coding standard is followed:
composer lint
orcomposer fix-style
to automatically fix it.
All versions of laravel-delay with dependencies
illuminate/contracts Version ^8.12|^9.0|^10.0
illuminate/support Version ^8.12|^9.0|^10.0
nesbot/carbon Version ^2.13