Package Data | |
---|---|
Maintainer Username: | Vinelab |
Maintainer Contact: | abed.halawi@vinelab.com (Abed Halawi) |
Package Create Date: | 2016-12-30 |
Package Last Update: | 2017-01-19 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-12 15:02:08 |
Package Statistics | |
---|---|
Total Downloads: | 118 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 4 |
Total Forks: | 2 |
Total Open Issues: | 0 |
Explore the details of scheduled events in a Laravel application.
There are times when you have too many schedules registered to run at different times, be it in the same application or multiple applications, i.e. in a micro-services architecture where multiple services have their work scheduled to perform different events at different times, it becomes crucial to have one central place that can navigate these scheduled events from across the different applications (services, projects, etc.). The way OClock achieves this is as follows:
before
hook on each of the events to store their session information in the database every time they start.after
hook on each of the events to:
is_running
will be marked as true
.composer require vinelab/oclock
OClock\OClockServiceProvider::class,
to the providers
array in config/app.php
config/database.php
as follows:'default' => env('DB_CONNECTION', 'mongodb'),
'connections' => [
'mongodb' => [
'driver' => 'mongodb',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 27017),
'database' => env('DB_DATABASE', 'logs'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'options' => [
'database' => 'admin' // sets the authentication database required by mongo 3
]
],
]
.env
file with the correct parameters# MongoDB
DB_HOST=localhost
DB_PORT=27017
DB_DATABASE=logs
DB_USERNAME=
DB_PASSWORD=
schedule
method of app/Console/Kernel.php
add the following to the bottom (after all the schedules have been defined):protected function schedule(Schedule $schedule)
{
// register schedules here
// ...
OClock::register($schedule);
}
Make sure you import the facade by adding use OClock;
to the top of the file.
OClock::sessions
: Get all the stored sessionsOClock::sessionsByDay
: Get all the sessions grouped by dayOClock::sessionsForEvent($eventId)
: Get the sessions for the given event