chrishardie / laravel-calendar-crawler
Laravel package to enable crawling web pages for event data, generating corresponding ICS feeds
Fund package maintenance!
ChrisHardie
Requires
- php: ^7.4|^8.0
- ext-json: *
- fabpot/goutte: ^4.0
- google/apiclient: ^2.0
- html2text/html2text: ^4.3
- illuminate/contracts: ^8.37
- spatie/icalendar-generator: ^2.3
- spatie/laravel-package-tools: ^1.4.3
Requires (Dev)
- nunomaduro/collision: ^5.3
- orchestra/testbench: ^6.15
- pestphp/pest: ^1.18
- pestphp/pest-plugin-laravel: ^1.1
- vimeo/psalm: ^4.8
This package is auto-updated.
Last update: 2024-11-03 18:57:02 UTC
README
Installation
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();
Usage
- 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.
Uninstalling
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');
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.