Download the PHP package kraenzle-ritter/resources-components without Composer
On this page you can find all versions of the php package kraenzle-ritter/resources-components. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kraenzle-ritter/resources-components
More information about kraenzle-ritter/resources-components
Files in kraenzle-ritter/resources-components
Package resources-components
Short Description Livewire components for resources
License MIT
Homepage https://github.com/kraenzle-ritter/resources-components
Informations about the package resources-components
Resources Components for Laravel
Search for entities in authority databases and link them with your local data using Livewire components. This package provides a seamless integration with various data providers to enhance your Laravel application with external resources.
Supported Providers
- GND (Gemeinsame Normdatei)
- Geonames (Geographical database)
- Wikipedia (Multiple languages: DE, EN, FR, IT)
- Wikidata (Structured data)
- Idiotikon (Swiss German dictionary)
- Ortsnamen.ch (Swiss place names)
- Metagrid (Swiss humanities database network)
- Anton API (Archives and collections)
- Manual Input (Custom links)
Requirements
- PHP 8.1 or higher
- Laravel 10.x or 11.x
- Livewire 3.4+
- kraenzle-ritter/resources package
Installation
Via Composer:
After installation, you can publish various assets:
Configuration
Publish the configuration file to customize provider settings:
This will create config/resources-components.php
where you can:
- Configure API endpoints and credentials
- Add custom providers
- Modify provider labels and URLs
- Set environment-specific settings (API tokens, etc.)
Language Files
Publish translation files for customization:
All Assets
Publish everything at once:
Testing
This package includes comprehensive tests to ensure proper functionality of all providers. Run the tests with:
Basic Usage
In your views, use the components like this:
Where:
$model
is the model that should become resourceable (must use theHasResources
trait)$providers
is an array of provider keys to enable (e.g.,['gnd', 'geonames', 'wikipedia-de', 'manual-input']
)- The third parameter (
'actors'
) is the endpoint entity type (only required for Anton API providers)
Configuration
The package comes with a pre-configured setup for various providers. After publishing the configuration file (see Installation), you can customize provider settings in config/resources-components.php
:
Provider Configuration Options
Each provider supports the following configuration options:
label
(string): Display name for the providerapi-type
(string): Provider class name (e.g., 'Gnd', 'Wikipedia', 'Wikidata')base_url
(string): Base URL for API requeststarget_url
(string): URL template for saved resources (supports placeholders like{provider_id}
)test_search
(string): Test query used by the provider check page to verify functionalitylimit
(integer, optional): Provider-specific result limit (overrides global limit)
Additional provider-specific options may apply (e.g., user_name
for Geonames, api_token
for Anton providers).
Creating Custom Providers
You can create your own provider by implementing the ProviderInterface
or extending the AbstractProvider
class:
-
Create a provider class:
- Register your provider in the configuration:
Customizing Views
You can publish and customize the views:
Handling Resource Events
The components fire an event (ResourceSaved
) when saving a resource. You can define and register a listener in your app:
Register your listener in EventServiceProvider.php
:
Configuration
Environment Variables
Some providers require additional configuration in your .env
file:
Model Requirements
Your models must:
- Use the
HasResources
trait from thekraenzle-ritter/resources
package - Have either a
resource_search
attribute or aname
attribute (used as default search term)
Creating Custom Providers
To create a new provider, you need:
- A provider class that implements the search functionality
- A Livewire component class for the UI interaction
- Configuration in the
resources-components.php
file
See the documentation or existing providers for implementation details.
License
MIT. Please see the license file for more information.
All versions of resources-components with dependencies
laravel/framework Version ^11.0
guzzlehttp/guzzle Version ^7.8
livewire/livewire Version ^3.4