PHPackages                             kraenzle-ritter/resources-components - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kraenzle-ritter/resources-components

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

kraenzle-ritter/resources-components
====================================

Livewire components for resources

v1.2.0(8mo ago)0385MITPHPPHP ^8.3CI passing

Since Oct 2Pushed 8mo ago3 watchersCompare

[ Source](https://github.com/kraenzle-ritter/resources-components)[ Packagist](https://packagist.org/packages/kraenzle-ritter/resources-components)[ Docs](https://github.com/kraenzle-ritter/resources-components)[ RSS](/packages/kraenzle-ritter-resources-components/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (6)Versions (22)Used By (0)

Package will not maintained anymore (2025-09-09)
================================================

[](#package-will-not-maintained-anymore-2025-09-09)

It is fully integrated in `kraenzle-ritter/resources` now.

Resources Components for Laravel
================================

[](#resources-components-for-laravel)

[![Latest Stable Version](https://camo.githubusercontent.com/caae5b302a42aacd866d469879f1084bae83d4813d584bb79b3a2fdd861dd9ae/68747470733a2f2f706f7365722e707567782e6f72672f6b7261656e7a6c652d7269747465722f7265736f75726365732d636f6d706f6e656e74732f76)](//packagist.org/packages/kraenzle-ritter/resources-components)[![Total Downloads](https://camo.githubusercontent.com/f8e9248ec0fc14cebfaf14a1655727cdea6303fe5f6c6670fe708f4f8a699b61/68747470733a2f2f706f7365722e707567782e6f72672f6b7261656e7a6c652d7269747465722f7265736f75726365732d636f6d706f6e656e74732f646f776e6c6f616473)](//packagist.org/packages/kraenzle-ritter/resources-components)[![License](https://camo.githubusercontent.com/d4082bb0bb3dd2f24913c56af3bb1883838e71429e512c8c6b85f96b3822809d/68747470733a2f2f706f7365722e707567782e6f72672f6b7261656e7a6c652d7269747465722f7265736f75726365732d636f6d706f6e656e74732f6c6963656e7365)](//packagist.org/packages/kraenzle-ritter/resources-components)[![Tests](https://github.com/kraenzle-ritter/resources-components/actions/workflows/php-tests.yml/badge.svg)](https://github.com/kraenzle-ritter/resources-components/actions/workflows/php-tests.yml)[![codecov](https://camo.githubusercontent.com/6902fb3bd73c0b58527f3e8cf705588d22c6ce332ac2952cb380a38b96389ab0/68747470733a2f2f636f6465636f762e696f2f67682f6b7261656e7a6c652d7269747465722f7265736f75726365732d636f6d706f6e656e74732f67726170682f62616467652e7376673f746f6b656e3d313342514a5649484f56)](https://codecov.io/gh/kraenzle-ritter/resources-components)

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
-------------------

[](#supported-providers)

- [GND](https://lobid.org/gnd) (Gemeinsame Normdatei)
- [Geonames](http://www.geonames.org/) (Geographical database)
- [Wikipedia](https://www.wikipedia.org/) (Multiple languages: DE, EN, FR, IT)
- [Wikidata](https://www.wikidata.org/) (Structured data)
- [Idiotikon](https://www.idiotikon.ch/) (Swiss German dictionary)
- [Ortsnamen.ch](https://ortsnamen.ch/) (Swiss place names)
- [Metagrid](https://metagrid.ch/) (Swiss humanities database network)
- [Anton API](https://anton.ch/) (Archives and collections)
    - [Archiv der Georg Fischer AG](https://archives.georgfischer.com)
    - [Gosteli Archiv](https://gosteli.anton.ch)
    - [Karl Barth-Archiv](https://kba.karl-barth.ch)
- Manual Input (Custom links)

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.x or 11.x
- Livewire 3.4+
- [kraenzle-ritter/resources](https://github.com/kraenzle-ritter/resources) package

Installation
------------

[](#installation)

Via Composer:

```
composer require kraenzle-ritter/resources-components
```

After installation, you can publish various assets:

### Configuration

[](#configuration)

Publish the configuration file to customize provider settings:

```
php artisan vendor:publish --tag=resources-components.config
```

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

[](#language-files)

Publish translation files for customization:

```
php artisan vendor:publish --tag=resources-components.lang
```

### All Assets

[](#all-assets)

Publish everything at once:

```
php artisan vendor:publish --provider="KraenzleRitter\ResourcesComponents\ResourcesComponentsServiceProvider"
```

Testing
-------

[](#testing)

This package includes comprehensive tests to ensure proper functionality of all providers. Run the tests with:

```
vendor/bin/phpunit
```

Basic Usage
-----------

[](#basic-usage)

In your views, use the components like this:

```
@livewire('resources-list', [$model, 'deleteButton' => true])
@livewire('provider-select', [$model, $providers, 'actors'])
```

Where:

- `$model` is the model that should become resourceable (must use the `HasResources` 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
-------------

[](#configuration-1)

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`:

```
// config/resources-components.php
return [
    'limit' => 5, // Default search results limit
    'providers' => [
        'gnd' => [
            'label' => 'GND',
            'api-type' => 'Gnd',
            'base_url' => 'https://lobid.org/gnd/',
            'target_url' => 'https://d-nb.info/gnd/{provider_id}',
            'test_search' => 'Hannah Arendt', // Test query for provider check page
        ],
        'wikipedia-de' => [
            'label' => 'Wikipedia (DE)',
            'api-type' => 'Wikipedia',
            'base_url' => 'https://de.wikipedia.org/w/api.php',
            'target_url' => 'https://de.wikipedia.org/wiki/{underscored_name}',
            'test_search' => 'Bertha von Suttner',
        ],
        // Add more providers here
    ],
];
```

### Provider Configuration Options

[](#provider-configuration-options)

Each provider supports the following configuration options:

- **`label`** (string): Display name for the provider
- **`api-type`** (string): Provider class name (e.g., 'Gnd', 'Wikipedia', 'Wikidata')
- **`base_url`** (string): Base URL for API requests
- **`target_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 functionality
- **`limit`** (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
-------------------------

[](#creating-custom-providers)

You can create your own provider by implementing the `ProviderInterface` or extending the `AbstractProvider` class:

1. Create a provider class:

```
namespace App\Providers;

use KraenzleRitter\ResourcesComponents\Providers\AbstractProvider;

class MyCustomProvider extends AbstractProvider
{
    public function search(string $search, array $params = [])
    {
        // Implement search logic
    }

    public function processResult($results): array
    {
        // Process results into standard format
        return [
            [
                'title' => 'Result title',
                'description' => 'Result description',
                'url' => 'https://example.com/resource',
                'raw_data' => json_encode($data)
            ],
            // More results...
        ];
    }
}
```

2. Register your provider in the configuration:

```
'my-provider' => [
    'label' => 'My Provider',
    'api-type' => 'MyCustom',
    'base_url' => 'https://api.example.com/',
    'provider_class' => App\Providers\MyCustomProvider::class,
],
```

Customizing Views
-----------------

[](#customizing-views)

You can publish and customize the views:

```
php artisan vendor:publish --provider="KraenzleRitter\ResourcesComponents\ResourcesComponentsServiceProvider" --tag=resources-components.views
```

### Handling Resource Events

[](#handling-resource-events)

The components fire an event (`ResourceSaved`) when saving a resource. You can define and register a listener in your app:

```
