Skip to content

Commit b83afc1

Browse files
committed
initial commit
0 parents  commit b83afc1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1354
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto
2+
*.md diff=markdown
3+
*.php diff=php
4+
/.github export-ignore
5+
/tests export-ignore
6+
.editorconfig export-ignore
7+
.gitattributes export-ignore
8+
.gitignore export-ignore
9+
docker-compose.yml export-ignore
10+
phpstan.neon export-ignore
11+
phpunit.xml.dist export-ignore

.github/workflows/tests.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
pull_request:
8+
branches:
9+
- '*'
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
tests:
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 30
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v3
26+
27+
- name: Setup PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: '8.1'
31+
coverage: none
32+
33+
- name: Get composer cache directory
34+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-files-dir)" >> $GITHUB_ENV
35+
36+
- name: Cache dependencies
37+
uses: actions/cache@v3
38+
with:
39+
path: ${{ env.COMPOSER_CACHE_DIR }}
40+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
41+
restore-keys: ${{ runner.os }}-composer-
42+
43+
- name: Install composer dependencies
44+
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
45+
46+
- name: Running Pint
47+
run: vendor/bin/pint --test
48+
49+
- name: Running PHPStan
50+
run: vendor/bin/phpstan analyse --error-format=github
51+
52+
- name: Running PHPUnit
53+
run: vendor/bin/phpunit

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/.phpunit.cache
2+
/vendor
3+
composer.phar
4+
composer.lock
5+
.DS_Store
6+
Thumbs.db
7+
/.idea
8+
/.fleet
9+
/.vscode
10+
.phpunit.result.cache

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM php:8.1.23-fpm
2+
3+
# Install dependencies
4+
RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \
5+
--mount=target=/var/cache/apt,type=cache,sharing=locked \
6+
rm -f /etc/apt/apt.conf.d/docker-clean \
7+
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache \
8+
&& apt-get update \
9+
&& apt-get install -y --no-install-recommends git unzip libffi-dev libvips42
10+
11+
RUN docker-php-ext-configure ffi --with-ffi \
12+
&& docker-php-ext-install -j$(nproc) ffi \
13+
&& ldconfig
14+
15+
# Install composer
16+
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

LICENSE

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) Mahmood Dehghani
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Laravel FileStorage package
2+
3+
## Installation
4+
### 1. Install the package via Composer:
5+
6+
```
7+
composer require imahmood/laravel-file-storage
8+
```
9+
10+
### 2. Publish the configuration file
11+
```bash
12+
php artisan vendor:publish --provider="Imahmood\FileStorage\FileStorageServiceProvider"
13+
```
14+
15+
## License
16+
17+
The MIT License (MIT). Please see [License File](LICENSE) for more information.

composer.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "imahmood/laravel-file-storage",
3+
"description": "Laravel file storage",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "Mahmood Dehghani",
8+
"email": "mahmood.public@gmail.com"
9+
}
10+
],
11+
"require": {
12+
"php": "^8.1",
13+
"jcupitt/vips": "^2.0",
14+
"laravel/framework": "^9.0|^10.0",
15+
"nesbot/carbon": "^2.0"
16+
},
17+
"require-dev": {
18+
"laravel/pint": "^1.0",
19+
"nunomaduro/larastan": "^2.6",
20+
"orchestra/testbench": "^8.11"
21+
},
22+
"autoload": {
23+
"psr-4": {
24+
"Imahmood\\FileStorage\\": "src/",
25+
"Imahmood\\FileStorage\\Database\\Factories\\": "database/factories/"
26+
}
27+
},
28+
"autoload-dev": {
29+
"psr-4": {
30+
"Imahmood\\FileStorage\\Tests\\": "tests/"
31+
}
32+
},
33+
"scripts": {
34+
"test": "vendor/bin/phpunit",
35+
"cs-check": "./vendor/bin/pint --test",
36+
"cs-fix": "./vendor/bin/pint",
37+
"stan": "./vendor/bin/phpstan analyse --memory-limit=-1"
38+
},
39+
"config": {
40+
"sort-packages": true
41+
},
42+
"minimum-stability": "stable",
43+
"prefer-stable": true,
44+
"extra": {
45+
"laravel": {
46+
"providers": [
47+
"Imahmood\\FileStorage\\FileStorageServiceProvider"
48+
]
49+
}
50+
}
51+
}

config/file-storage.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
return [
4+
'disk' => env('FILE_STORAGE_DISK', 'media'),
5+
'queue' => env('FILE_STORAGE_QUEUE', 'media'),
6+
'max_dimension' => env('FILE_STORAGE_MAX_DIMENSION', 2000),
7+
'preview_dimension' => env('FILE_STORAGE_PREVIEW_DIMENSION', 300),
8+
];
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Imahmood\FileStorage\Database\Factories;
6+
7+
use Illuminate\Database\Eloquent\Factories\Factory;
8+
use Imahmood\FileStorage\Models\Media;
9+
10+
class MediaFactory extends Factory
11+
{
12+
/**
13+
* @var class-string<\Imahmood\FileStorage\Models\Media>
14+
*/
15+
protected $model = Media::class;
16+
17+
/**
18+
* @throws \Exception
19+
*/
20+
public function definition(): array
21+
{
22+
return [
23+
'model_type' => 'App/Models/User',
24+
'model_id' => 1,
25+
'file_name' => 'fake-file.jpg',
26+
'type' => 1,
27+
];
28+
}
29+
}

0 commit comments

Comments
 (0)