Skip to content

Commit 55ec48e

Browse files
Add Integration for Laravel (#136)
0 parents  commit 55ec48e

12 files changed

+7448
-0
lines changed

.gitattributes

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.gitattributes export-ignore
2+
.gitignore export-ignore
3+
composer.lock export-ignore
4+
/Tests export-ignore
5+
phpunit.xml.dist export-ignore
6+
.php-cs-fixer.dist.php export-ignore
7+
phpstan.neon export-ignore
8+
rector.php export-ignore

.github/FUNDING.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: [alexander-schranz]
2+
custom: ["https://paypal.me/L91"]

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/vendor/
2+
/composer.phar
3+
/phpunit.xml
4+
/.phpunit.result.cache
5+
/.phpunit.cache/
6+
/tests/var
7+
/docker-compose.override.yml
8+
/.php-cs-fixer.php
9+
/.php-cs-fixer.cache

.php-cs-fixer.dist.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$phpCsConfig = require(dirname(__DIR__, 2) . '/.php-cs-fixer.dist.php');
6+
7+
$finder = (new PhpCsFixer\Finder())
8+
->in(__DIR__)
9+
->ignoreVCSIgnored(true);
10+
11+
$phpCsConfig->setFinder($finder);
12+
13+
return $phpCsConfig->setFinder($finder);

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Alexander Schranz
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
<div align="center">
2+
<img alt="Schranz Search Logo with a Seal on it with a magnifying glass" src="https://avatars.githubusercontent.com/u/120221538?s=400&v=5" width="200" height="200">
3+
</div>
4+
5+
<h1 align="center">Schranz Search SEAL <br /> Laravel Integration</h1>
6+
7+
<br />
8+
<br />
9+
10+
Integration of the Schranz Search — Search Engine Abstraction Layer (SEAL) into Laravel.
11+
12+
> **Note**:
13+
> This is part of the `schranz-search/schranz-search` project create issues in the [main repository](https://github.com/schranz-search/schranz-search).
14+
15+
> **Note**:
16+
> This project is heavily under development and any feedback is greatly appreciated.
17+
18+
## Installation
19+
20+
Use [composer](https://getcomposer.org/) for install the package:
21+
22+
```bash
23+
composer require schranz-search/laravel-integration
24+
```
25+
26+
Also install one of the listed adapters.
27+
28+
### List of adapters
29+
30+
The following adapters are available:
31+
32+
- [MemoryAdapter](../../packages/seal-memory-adapter): `schranz-search/seal-memory-adapter`
33+
- [ElasticsearchAdapter](../../packages/seal-elasticsearch-adapter): `schranz-search/seal-elasticsearch-adapter`
34+
- [OpensearchAdapter](../../packages/seal-opensearch-adapter): `schranz-search/seal-opensearch-adapter`
35+
- [MeilisearchAdapter](../../packages/seal-meilisearch-adapter): `schranz-search/seal-meilisearch-adapter`
36+
- [AlgoliaAdapter](../../packages/seal-algolia-adapter): `schranz-search/seal-algolia-adapter`
37+
- [SolrAdapter](../../packages/seal-solr-adapter): `schranz-search/seal-solr-adapter`
38+
- [RediSearchAdapter](../../packages/seal-redisearch-adapter): `schranz-search/seal-redisearch-adapter`
39+
- [TypesenseAdapter](../../packages/seal-typesense-adapter): `schranz-search/seal-typesense-adapter`
40+
- ... more coming soon
41+
42+
Additional Wrapper adapters:
43+
44+
- [ReadWriteAdapter](../../packages/seal-read-write-adapter)
45+
- [MultiAdapter](../../packages/seal-multi-adapter)
46+
47+
Creating your own adapter? Add the [`seal-php-adapter`](https://github.com/topics/seal-php-adapter) Topic to your Github Repository.
48+
49+
## Usage.
50+
51+
The following code shows how to configure the package:
52+
53+
```php
54+
<?php
55+
56+
return [
57+
/*
58+
|--------------------------------------------------------------------------
59+
| Schema configs
60+
|--------------------------------------------------------------------------
61+
|
62+
| Define different directories for the schema loader.
63+
*/
64+
65+
'schemas' => [
66+
'app' => [
67+
'dir' => resource_path('schemas'),
68+
],
69+
],
70+
71+
/*
72+
|--------------------------------------------------------------------------
73+
| engines
74+
|--------------------------------------------------------------------------
75+
|
76+
| Directory where the latte templates can be found.
77+
*/
78+
79+
'engines' => [
80+
'default' => [
81+
'adapter' => env(
82+
'ENGINE_URL',
83+
'meilisearch://127.0.0.1:7700',
84+
),
85+
],
86+
],
87+
];
88+
```
89+
90+
A more complex configuration can be here found:
91+
92+
```php
93+
<?php
94+
95+
return [
96+
/*
97+
|--------------------------------------------------------------------------
98+
| Schema configs
99+
|--------------------------------------------------------------------------
100+
|
101+
| Define different directories for the schema loader.
102+
*/
103+
104+
'schemas' => [
105+
'app' => [
106+
'dir' => resource_path('schemas') . '/app',
107+
'engine' => 'meilisearch',
108+
],
109+
'other' => [
110+
'dir' => resource_path('schemas') . '/other',
111+
'engine' => 'algolia',
112+
],
113+
],
114+
115+
/*
116+
|--------------------------------------------------------------------------
117+
| engines
118+
|--------------------------------------------------------------------------
119+
|
120+
| Directory where the latte templates can be found.
121+
*/
122+
123+
'engines' => [
124+
'algolia' => [
125+
'adapter' => 'algolia://%env(ALGOLIA_APPLICATION_ID)%:%env(ALGOLIA_ADMIN_API_KEY)%',
126+
],
127+
'elasticsearch' => [
128+
'adapter' => 'elasticsearch://127.0.0.1:9200',
129+
],
130+
'meilisearch' => [
131+
'adapter' => 'meilisearch://127.0.0.1:7700',
132+
],
133+
'memory' => [
134+
'adapter' => 'memory://',
135+
],
136+
'opensearch' => [
137+
'adapter' => 'opensearch://127.0.0.1:9200',
138+
],
139+
'redisearch' => [
140+
'adapter' => 'redis://[email protected]:6379',
141+
],
142+
'solr' => [
143+
'adapter' => 'solr://127.0.0.1:8983',
144+
],
145+
'typesense' => [
146+
'adapter' => 'typesense://[email protected]:8108',
147+
],
148+
149+
// ...
150+
'multi' => [
151+
'adapter' => 'multi://elasticsearch?adapters[]=opensearch',
152+
],
153+
'read-write' => [
154+
'adapter' => 'read-write://elasticsearch?write=multi',
155+
],
156+
],
157+
];
158+
```
159+
160+
The default engine is available as `Engine`:
161+
162+
```php
163+
class Some {
164+
public function __construct(
165+
private readonly \Schranz\Search\SEAL\Engine $engine,
166+
) {
167+
}
168+
}
169+
```
170+
171+
Multiple engines can be accessed via the `EngineRegistry`:
172+
173+
```php
174+
class Some {
175+
public function __construct(
176+
private readonly \Schranz\Search\SEAL\EngineRegistry $engineRegistry,
177+
) {
178+
}
179+
}
180+
```
181+
182+
How to create a `Schema` file and use your `Engine` can be found [SEAL Documentation](../../README.md#usage).
183+
184+
## Authors
185+
186+
- [Alexander Schranz](https://github.com/alexander-schranz/)
187+
- [The Community Contributors](https://github.com/schranz-search/schranz-search/graphs/contributors)

composer.json

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"name": "schranz-search/laravel-integration",
3+
"description": "An integration of schranz-search search abstraction into Laravel Framework.",
4+
"type": "library",
5+
"license": "MIT",
6+
"keywords": [
7+
"search-client",
8+
"search-abstraction",
9+
"abstraction",
10+
"search",
11+
"search-client",
12+
"search-abstraction",
13+
"schranz-search",
14+
"elasticsearch",
15+
"opensearch",
16+
"meilisearch",
17+
"typesense",
18+
"solr",
19+
"redisearch",
20+
"algolia",
21+
"integration",
22+
"module",
23+
"laravel"
24+
],
25+
"autoload": {
26+
"psr-4": {
27+
"Schranz\\Search\\Integration\\Laravel\\": "src"
28+
},
29+
"exclude-from-classmap": [
30+
"/Tests/"
31+
]
32+
},
33+
"autoload-dev": {
34+
"psr-4": {
35+
"Schranz\\Search\\Integration\\Laravel\\Tests\\": "tests"
36+
}
37+
},
38+
"authors": [
39+
{
40+
"name": "Alexander Schranz",
41+
"email": "[email protected]"
42+
}
43+
],
44+
"require": {
45+
"php": "^8.1",
46+
"illuminate/view": "^8.0 || ^9.0 || ^10.0",
47+
"illuminate/support": "^8.0 || ^9.0 || ^10.0",
48+
"schranz-search/seal": "^0.1"
49+
},
50+
"require-dev": {
51+
"php-cs-fixer/shim": "^3.15",
52+
"phpstan/extension-installer": "^1.2",
53+
"phpstan/phpstan": "^1.10",
54+
"phpstan/phpstan-phpunit": "^1.3",
55+
"phpunit/phpunit": "^9.5.27",
56+
"rector/rector": "^0.15.23",
57+
"schranz-search/seal-algolia-adapter": "^0.1",
58+
"schranz-search/seal-elasticsearch-adapter": "^0.1",
59+
"schranz-search/seal-meilisearch-adapter": "^0.1",
60+
"schranz-search/seal-memory-adapter": "^0.1",
61+
"schranz-search/seal-multi-adapter": "^0.1",
62+
"schranz-search/seal-opensearch-adapter": "^0.1",
63+
"schranz-search/seal-read-write-adapter": "^0.1",
64+
"schranz-search/seal-redisearch-adapter": "^0.1",
65+
"schranz-search/seal-solr-adapter": "^0.1",
66+
"schranz-search/seal-typesense-adapter": "^0.1"
67+
},
68+
"conflict": {
69+
"schranz-search/seal-algolia-adapter": "<0.1, >=0.2",
70+
"schranz-search/seal-elasticsearch-adapter": "<0.1, >=0.2",
71+
"schranz-search/seal-meilisearch-adapter": "<0.1, >=0.2",
72+
"schranz-search/seal-memory-adapter": "<0.1, >=0.2",
73+
"schranz-search/seal-multi-adapter": "<0.1, >=0.2",
74+
"schranz-search/seal-opensearch-adapter": "<0.1, >=0.2",
75+
"schranz-search/seal-read-write-adapter": "<0.1, >=0.2",
76+
"schranz-search/seal-redisearch-adapter": "<0.1, >=0.2",
77+
"schranz-search/seal-solr-adapter": "<0.1, >=0.2",
78+
"schranz-search/seal-typesense-adapter": "<0.1, >=0.2"
79+
},
80+
"scripts": {
81+
"test": [
82+
"Composer\\Config::disableProcessTimeout",
83+
"vendor/bin/phpunit"
84+
],
85+
"phpstan": "@php vendor/bin/phpstan analyze",
86+
"lint-rector": "@php vendor/bin/rector process --dry-run",
87+
"lint-php-cs": "@php vendor/bin/php-cs-fixer fix --verbose --diff --dry-run",
88+
"lint": [
89+
"@phpstan",
90+
"@lint-php-cs",
91+
"@lint-rector"
92+
],
93+
"rector": "@php vendor/bin/rector process",
94+
"php-cs-fix": "@php vendor/bin/php-cs-fixer fix",
95+
"fix": [
96+
"@rector",
97+
"@php-cs-fix"
98+
]
99+
},
100+
"repositories": [
101+
{
102+
"type": "path",
103+
"url": "./../../packages/*",
104+
"options": {
105+
"symlink": true
106+
}
107+
}
108+
],
109+
"minimum-stability": "dev",
110+
"config": {
111+
"allow-plugins": {
112+
"php-http/discovery": true,
113+
"phpstan/extension-installer": true
114+
}
115+
},
116+
"extra": {
117+
"laravel": {
118+
"providers": [
119+
"Schranz\\Search\\Integration\\Laravel\\SearchProvider"
120+
]
121+
}
122+
}
123+
}

0 commit comments

Comments
 (0)