Download the PHP package cardei/link-preview without Composer
On this page you can find all versions of the php package cardei/link-preview. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package link-preview
Laravel Link π Preview (Ξ²ETA) π§ WIP - Work In Progress
Link preview generation π οΈ for Laravel π applications. This package π¦ generates link previews for Laravel applications, similar to how social media platforms display link previews when a URL is shared.
Features π
- Automatic Metadata Extraction π: Extracts titles π·οΈ, descriptions π, and images πΌοΈ from URLs to generate rich link previews.
- Supports Popular Platforms π: Built-in support for platforms like YouTube βΆοΈ and Vimeo π₯ for embedded previews.
- Customizable Configuration βοΈ: Fine-tune π§ the package to meet your application's specific requirements.
- Laravel Integration π€: Seamlessly integrates into your Laravel projects with service providers and facades.
- Simple Usage π: Easy to implement in any controller ποΈ or service.
Compatibility β
- PHP Version: PHP >= 8.2 π
- Laravel Versions: Laravel 10.x and 11.x π
Dependencies π¦
- Guzzle (
guzzlehttp/guzzle
): ^7.4 - For HTTP π requests to fetch URL metadata. - Symfony Dom Crawler (
symfony/dom-crawler
): ^7.0 - For parsing HTML content π. - Symfony CSS Selector (
symfony/css-selector
): ^7.0 - For extracting metadata from the parsed HTML.
Installation π οΈ
To install the package via Composer, run the following command:
After installation, you can publish the configuration file if you need to customize the settings:
This will create a configuration file at config/link-preview.php
.
Requirements π
- PHP >= 8.2 π
- Laravel 10.x or 11.x π
Configuration βοΈ
The package provides a configuration file that can be published using the vendor:publish
command. By default, the package includes basic configuration for logging π and URL processing:
enable_logging
: If set totrue
β , the package will log information about the URLs being processed whenAPP_DEBUG=true
.
To enable logging, you can add the following to your .env
file:
Usage π»
Generating Link Previews π
The package automatically detects URLs and generates previews using metadata from the target URL (e.g., titles π·οΈ, images πΌοΈ, descriptions π). It supports platforms such as YouTube βΆοΈ, Vimeo π₯, and general HTML pages π.
To use the package, simply call the link-preview
service in your Laravel controllers or services:
You can then access metadata like title
π·οΈ, description
π, and cover image
πΌοΈ from the $preview
object.
Supported Platforms π
- YouTube βΆοΈ: Automatically generates embedded previews for YouTube links. Note: Integration with the YouTube API is required for optimal performance. This is particularly important when running the package from cloud instances, as direct page scraping for YouTube links might fail due to network restrictions or bot detection mechanisms. Using the YouTube API ensures consistent and reliable previews.
- Vimeo π₯: Similar to YouTube, generates embedded previews for Vimeo links.
- General HTML Links π: Extracts metadata such as titles π·οΈ, descriptions π, and images πΌοΈ from any general webpage.
Why Use Laravel Link Preview? π€
- Simplicity π: This package is designed to be easy to integrate and use within any Laravel project, with minimal configuration required.
- Rich Integration π: Direct integration with Laravel services and easy access via facades.
- Customizable βοΈ: Configuration options allow you to tailor the package's behavior to your specific needs, including the ability to add new parsers.
- Actively Developed π οΈ: Ongoing support and compatibility with the latest versions of Laravel.
Integration π€
The package provides seamless integration into your Laravel projects by including:
- Service Providers π οΈ: The
LaravelServiceProvider
is automatically registered. - Facades π·οΈ: Use the provided facade to easily access the
link-preview
functionality.
Example: Using in a Controller π
TODO π
- Support More Platforms π: Expand support for additional platforms, such as SoundCloud πΆ and TikTok π΅.
- Advanced Error Handling β οΈ: Improve error handling for failed previews.
- Caching ποΈ: Implement caching for previews to avoid multiple requests for the same URL.
- Internationalization π: Add support for parsing metadata in different languages.
Versioning and Branches π
- v1.0.0 - 1.0.1: Supports Laravel 10.x π
- v2.x: Supports Laravel 11.x and newer versions π
Branches:
main
π: Default branch with the latest stable version ready for production.dev-main
π οΈ: Development branch with the latest updates.2.1.0-DEV
π§: Latest development version for Laravel 11.x support.
Documentation π
For detailed documentation, refer to the GitHub Wiki.
Contributing π€
Contributions are always welcome! If you'd like to contribute, please fork this repository, make your changes, and submit a pull request π₯.
License π
This package is open-sourced software licensed under the MIT license.
Support π
For issues and feature requests, please visit the GitHub Issues page.
If you have any questions or need support, you can contact M. Catalin Cardei.
Why Laravel Link Preview is Better? π
- Native Laravel Integration π€: Unlike other link preview libraries that require extensive setup, this package is designed with Laravel in mind, providing native support for service providers and facades.
- Modular Parser System π§: The parser system allows for easy addition of custom parsers, making it extensible.
- Lightweight and Fast β‘: Optimized for performance, it does not add unnecessary overhead to your application.
- Open Source and Transparent π: The code is available on GitHub, providing transparency and the ability to modify the package to fit your needs.
All versions of link-preview with dependencies
illuminate/support Version 5.*|6.*|7.*|8.*|9.*
guzzlehttp/guzzle Version ^6.1|^7.1
symfony/dom-crawler Version ^3.0|^4.0|^5.0|^6.0
symfony/css-selector Version ^3.0|^4.0|^5.0|^6.0