Skip to content

Commit 943acec

Browse files
committed
wip
0 parents  commit 943acec

18 files changed

+3131
-0
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: larsklopstra

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor
2+
/.idea
3+
/.vscode
4+
/.php-cs-fixer.cache

.php-cs-fixer.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
$finder = Symfony\Component\Finder\Finder::create()
4+
->in([
5+
__DIR__ . '/src',
6+
__DIR__ . '/routes',
7+
])
8+
->name('*.php')
9+
->notName('*.blade.php')
10+
->ignoreDotFiles(true)
11+
->ignoreVCS(true);
12+
13+
return (new PhpCsFixer\Config())
14+
->setRules([
15+
'@PSR12' => true,
16+
'array_syntax' => ['syntax' => 'short'],
17+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
18+
'no_unused_imports' => true,
19+
'not_operator_with_successor_space' => true,
20+
'trailing_comma_in_multiline' => true,
21+
'phpdoc_scalar' => true,
22+
'unary_operator_spaces' => true,
23+
'binary_operator_spaces' => true,
24+
'blank_line_before_statement' => [
25+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
26+
],
27+
'phpdoc_single_line_var_spacing' => true,
28+
'phpdoc_var_without_name' => true,
29+
'class_attributes_separation' => [
30+
'elements' => [
31+
'method' => 'one',
32+
],
33+
],
34+
'method_argument_space' => [
35+
'on_multiline' => 'ensure_fully_multiline',
36+
'keep_multiple_spaces_after_comma' => true,
37+
],
38+
'single_trait_insert_per_statement' => true,
39+
])
40+
->setFinder($finder);

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Flowframe <[email protected]>
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
13+
all 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
21+
THE SOFTWARE.

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Laravel Drift
2+
3+
Optimize images on the fly.
4+
5+
## Installation
6+
7+
You can install the package via composer:
8+
9+
```
10+
composer require flowframe/laravel-drift
11+
```
12+
13+
## Usage
14+
15+
Simply install the package, and register a configuration in `AppServiceProvider@boot`:
16+
17+
```php
18+
use Flowframe\Drift\Config;
19+
use Flowframe\Drift\DriftManager;
20+
use Flowframe\Drift\CachingStrategies\FilesystemCachingStrategy;
21+
22+
/** @var DriftManager $drift */
23+
$drift = app(DriftManager::class);
24+
25+
$drift->registerConfig(new Config(
26+
name: 'my-config-name', // Will be used in the slug
27+
filesystemDisk: 'filesystems-disk-name', // Local, public or s3 for example
28+
cachingStrategy: FilesystemCachingStrategy::class, // Create your own or use the defaults like FilesystemCachingStrategy or NullCachingStrategy
29+
));
30+
```
31+
32+
### Image URLs
33+
34+
To generate an image URL use the `\Flowframe\Drift\UrlBuilder` like so:
35+
36+
```php
37+
use Flowframe\Drift\UrlBuilder;
38+
39+
/** @var UrlBuilder $builder */
40+
$builder = app(UrlBuilder::class);
41+
42+
$image = $builder->url('my-config-name', 'example.png', [
43+
'resize' => [1920, 1080],
44+
'encode' => 'webp', // The fallback encoding will be webp
45+
]);
46+
```
47+
48+
You can use most of [Intervention Image's](https://image.intervention.io/v2/usage/overview#editing-images) methods, simply use the method name as key and set the argument as value. Have more than one argument? Use an array instead like in the example above.
49+
50+
### Blade Component
51+
52+
```blade
53+
<x-drift::image
54+
class="w-full aspect-[16/9] object-cover"
55+
config="my-config-name"
56+
path="example.png"
57+
:manipulations="[
58+
'encode' => ['jpeg', 50],
59+
'greyscale' => true,
60+
]"
61+
/>
62+
```

composer.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "flowframe/laravel-drift",
3+
"type": "library",
4+
"license": "MIT",
5+
"homepage": "https://github.com/flowframe/laravel-drift",
6+
"autoload": {
7+
"psr-4": {
8+
"Flowframe\\Drift\\": "src"
9+
}
10+
},
11+
"authors": [
12+
{
13+
"name": "Lars Klopstra",
14+
"email": "[email protected]"
15+
}
16+
],
17+
"require": {
18+
"php": "^8.0",
19+
"illuminate/support": "^9.4",
20+
"intervention/image": "^2.7",
21+
"illuminate/http": "^9.4"
22+
},
23+
"extra": {
24+
"laravel": {
25+
"providers": [
26+
"Flowframe\\Drift\\DriftServiceProvider"
27+
]
28+
}
29+
},
30+
"minimum-stability": "dev",
31+
"prefer-stable": true
32+
}

0 commit comments

Comments
 (0)