vaweto / laravel-medium
This package hepls to fetch a recent feed of a medium.com
Requires
- php: ^8.1
- ext-simplexml: *
- guzzlehttp/guzzle: ^7.8
- illuminate/contracts: ^10.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.8
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.8
- pestphp/pest: ^2.20
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2025-03-29 01:08:02 UTC
README
With this package you can get the rss feed of any valid Medium tag or user you want as objects in order to make a feed on you application. You can use your database to store the feeds you want to watch or you can call them hardcoded by specify the name of the feed and the type of the feed (user or tag).
Here's a quick example:
Usage
Get a specific feed hardcoded
use Vaweto\Medium\Facades\Medium; use Vaweto\Medium\Definitions\MediumFeedType; $articles = Medium::getFeed('laravel', MediumFeedType::TAG)->getArticles();
Get a specific feed from database
use Vaweto\Medium\Facades\Medium; use Vaweto\Medium\Models\MediumFeed; $mediumFeed = MediumFeed::query()->first(); $articles = Medium::getFeed(mediumFeed)->getArticles();
Get a multiple feeds from database
use Vaweto\Medium\Facades\Medium; use Vaweto\Medium\Models\MediumFeed; $mediumFeeds = MediumFeed::query()->all(); $articles = Medium::all(mediumFeeds);
Use it in your controller
use Vaweto\Medium\Facades\Medium; use Vaweto\Medium\Models\MediumFeed; class MediumFeedControllerController { public function __invoke(Invoice $invoice) { $articles = Medium::all(MediumFeed::query()->all()); return view('your-feed-blade', compact('articles')); } }
And on your blade
@foreach ($articles as $article) <div> <h2>{{ $article->title }}</h2> <p>{{ $article->pubDate->toDateTimeString() }}</p> <a href="{{ $article->guid }}" target="_blank">Read More</a> </div> @endforeach
Installation
You can install the package via composer:
composer require vaweto/laravel-medium
You can publish and run the migrations with:
php artisan vendor:publish --tag="medium-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="medium-config"
This is the contents of the published config file:
return [ 'api_token' => env('MEDIUM_API_TOKEN'), 'feed_urls' => [ 'user' => 'https://medium.com/feed/', 'tag' => 'https://medium.com/feed/tag/', ], 'caching' => [ 'enabled' => env('MEDIUM_CACHING', false), 'time_in_seconds' => env('MEDIUM_CACHING_TIME_IN_SECONDS', 120), ], ];
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.