You can install the package via composer:
composer require chrishardie/laravel-calendar-crawler
You can publish and run the migrations with:
php artisan vendor:publish --provider="ChrisHardie\CalendarCrawler\CalendarCrawlerServiceProvider" --tag="calendar-crawler-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --provider="ChrisHardie\CalendarCrawler\CalendarCrawlerServiceProvider" --tag="calendar-crawler-config"
This is the contents of the published config file:
return [
'default_update_frequency' => 720, // Refresh every 12 hours
'calendar_name' => 'Calendar of Events',
'calendar_description' => 'A calendar of events from various sources.',
// Default URL of calendar ICS feed
'stream_url' => '/calendar/calendar.ics',
// Source-specific authentication information
'auth' => [
'google' => [
'api_key' => env('GOOGLE_CAL_API_KEY'),
]
],
];
You can add a web route for a calendar ICS feed of all stored events:
Route::calendarstream();
- Use an admin interface, artisan tinker session, DB seeder file or direct database call to add calendar sources. The main fields needed are:
- Name
- Type (currently,
GoogleCalendar
orFacebookPage
) - Home URL
- Location (either the Google Calendar calendar ID or the Facebook Page's numeric page ID)
DB::table('calendar_sources')->insert([
'name' => 'Your Local Government',
'type' => 'GoogleCalendar',
'home_url' => 'https://www.government.gov/',
'location' => 'googlecalendarid@gmail.com',
]);
DB::table('calendar_sources')->insert([
'name' => 'Cool Nonprofit Organization',
'type' => 'FacebookPage',
'home_url' => 'https://www.facebook.com/orgname/',
'location' => '12345678',
]);
- If you specify any GoogleCalendar sources, you will need to create an API key and then define a
GOOGLE_CAL_API_KEY
with that key as the value in your.env
file. - The sources provided will be crawled according to the update frequency specified.
- Use the event data elsewhere within your Laravel application directly, or retrieve an ICS calendar feed of events at the
stream_url
location specified.
Crawling issues, errors and notices will be written to the log stack configured. Consider using a Slack channel for convenience.
Remove any web routes created during installation.
Remove the package and any dependencies:
composer remove chrishardie/laravel-calendar-crawler
Remove config/calendar-crawler.php
.
Drop the related tables in a new migration:
Schema::dropIfExists('calendar_sources');
Schema::dropIfExists('events');
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.