Skip to content
This repository was archived by the owner on Feb 18, 2023. It is now read-only.

Commit b122def

Browse files
authored
Merge pull request #76 from joselfonseca/feature/remove-dingo
Re write with less dependencies and easier set up
2 parents 312ea10 + bc2b898 commit b122def

File tree

102 files changed

+7400
-6181
lines changed

Some content is hidden

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

102 files changed

+7400
-6181
lines changed

.env.example

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,49 @@
1+
APP_NAME=Laravel
12
APP_ENV=local
3+
APP_KEY=
24
APP_DEBUG=true
3-
APP_KEY=base64:JqyMTmt5qr1CW6BH+GG+4iKfU4RiNjZTLy33TdTT7+4=
5+
APP_URL=http://localhost
46

5-
API_STANDARDS_TREE=vnd
6-
API_SUBTYPE=api
7-
API_PREFIX=api
8-
API_VERSION=v1
9-
API_DEBUG=true
7+
LOG_CHANNEL=stack
8+
LOG_LEVEL=debug
109

11-
DB_HOST=mysql
12-
DB_DATABASE=api
10+
DB_CONNECTION=mysql
11+
DB_HOST=127.0.0.1
12+
DB_PORT=3306
13+
DB_DATABASE=laravel
1314
DB_USERNAME=root
14-
DB_PASSWORD=secret
15+
DB_PASSWORD=
1516

17+
BROADCAST_DRIVER=log
1618
CACHE_DRIVER=file
19+
QUEUE_CONNECTION=sync
1720
SESSION_DRIVER=file
18-
QUEUE_DRIVER=sync
21+
SESSION_LIFETIME=120
1922

20-
MAIL_DRIVER=smtp
21-
MAIL_HOST=mailtrap.io
22-
MAIL_PORT=2525
23+
MEMCACHED_HOST=127.0.0.1
24+
25+
REDIS_HOST=127.0.0.1
26+
REDIS_PASSWORD=null
27+
REDIS_PORT=6379
28+
29+
MAIL_MAILER=smtp
30+
MAIL_HOST=mailhog
31+
MAIL_PORT=1025
2332
MAIL_USERNAME=null
2433
MAIL_PASSWORD=null
25-
MAIL_ENCRYPTION=null
34+
MAIL_ENCRYPTION=null
35+
MAIL_FROM_ADDRESS=null
36+
MAIL_FROM_NAME="${APP_NAME}"
37+
38+
AWS_ACCESS_KEY_ID=
39+
AWS_SECRET_ACCESS_KEY=
40+
AWS_DEFAULT_REGION=us-east-1
41+
AWS_BUCKET=
42+
43+
PUSHER_APP_ID=
44+
PUSHER_APP_KEY=
45+
PUSHER_APP_SECRET=
46+
PUSHER_APP_CLUSTER=mt1
47+
48+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
49+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.github/workflows/run-tests.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: "Run Tests - Current"
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
php: [8.0, 7.4]
12+
13+
name: P${{ matrix.php }}
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
19+
- name: Cache dependencies
20+
uses: actions/cache@v2
21+
with:
22+
path: ~/.composer/cache/files
23+
key: dependencies-laravel-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
24+
25+
- name: Setup PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php }}
29+
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv
30+
coverage: none
31+
32+
- name: Install dependencies
33+
run: |
34+
composer install
35+
php -r "copy('.env.example', '.env');"
36+
php artisan key:generate
37+
php artisan passport:keys
38+
- name: Execute tests
39+
run: vendor/bin/phpunit

.php_cs.dist

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
use PhpCsFixer\Finder;
4+
5+
$project_path = getcwd();
6+
$finder = Finder::create()
7+
->in([
8+
$project_path . '/app',
9+
$project_path . '/config',
10+
$project_path . '/database',
11+
$project_path . '/resources',
12+
$project_path . '/routes',
13+
$project_path . '/tests',
14+
])
15+
->name('*.php')
16+
->notName('*.blade.php')
17+
->ignoreDotFiles(true)
18+
->ignoreVCS(true);
19+
20+
return \ShiftCS\styles($finder);

.travis.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

app/Console/Commands/InstallApp.php

Lines changed: 0 additions & 55 deletions
This file was deleted.

app/Console/Kernel.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace App\Console;
44

5-
use App\Console\Commands\InstallApp;
65
use Illuminate\Console\Scheduling\Schedule;
76
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
87

@@ -14,7 +13,7 @@ class Kernel extends ConsoleKernel
1413
* @var array
1514
*/
1615
protected $commands = [
17-
InstallApp::class,
16+
1817
];
1918

2019
/**
@@ -26,7 +25,6 @@ class Kernel extends ConsoleKernel
2625
*/
2726
protected function schedule(Schedule $schedule)
2827
{
29-
$schedule->call('demo:reset')->hourly();
3028
}
3129

3230
/**

app/Exceptions/Handler.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
namespace App\Exceptions;
44

5+
use Illuminate\Auth\AuthenticationException;
56
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
7+
use Illuminate\Validation\ValidationException;
8+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
69
use Throwable;
710

811
/**
@@ -47,6 +50,39 @@ public function report(Throwable $exception)
4750
*/
4851
public function render($request, Throwable $exception)
4952
{
53+
if ($exception instanceof AuthenticationException) {
54+
return response()->json([
55+
'message' => 'Unauthenticated.',
56+
'status_code' => 401,
57+
], 401);
58+
}
59+
if ($exception instanceof BodyTooLargeException) {
60+
return response()->json([
61+
'message' => 'The body is too large',
62+
'status_code' => 413,
63+
], 413);
64+
}
65+
if ($exception instanceof ValidationException) {
66+
return response()->json([
67+
'message' => $exception->getMessage(),
68+
'status_code' => 422,
69+
'errors' => $exception->errors(),
70+
], 422);
71+
}
72+
if ($exception instanceof StoreResourceFailedException) {
73+
return response()->json([
74+
'message' => $exception->getMessage(),
75+
'status_code' => 422,
76+
'errors' => $exception->errors,
77+
], 422);
78+
}
79+
if ($exception instanceof NotFoundHttpException) {
80+
return response()->json([
81+
'message' => '404 Not Found',
82+
'status_code' => 404,
83+
], 404);
84+
}
85+
5086
return parent::render($request, $exception);
5187
}
5288
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Exception;
6+
use Throwable;
7+
8+
class StoreResourceFailedException extends Exception
9+
{
10+
public $errors = [];
11+
12+
public function __construct($message = '', $errors = [], $code = 0, Throwable $previous = null)
13+
{
14+
parent::__construct($message, $code, $previous);
15+
$this->errors = $errors;
16+
}
17+
}

app/Http/Controllers/Api/Assets/RenderFileController.php

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,15 @@
99
use Illuminate\Support\Facades\Storage;
1010
use Intervention\Image\Facades\Image;
1111

12-
/**
13-
* Class RenderFileController.
14-
*/
1512
class RenderFileController extends Controller
1613
{
17-
/**
18-
* @var \App\Models\Asset
19-
*/
2014
protected $model;
2115

22-
/**
23-
* RenderFileController constructor.
24-
*
25-
* @param \App\Models\Asset $model
26-
*/
2716
public function __construct(Asset $model)
2817
{
2918
$this->model = $model;
3019
}
3120

32-
/**
33-
* @param $uuid
34-
* @param \Illuminate\Http\Request $request
35-
* @return mixed
36-
*/
3721
public function show($uuid, Request $request)
3822
{
3923
try {
@@ -45,24 +29,13 @@ public function show($uuid, Request $request)
4529
}
4630
}
4731

48-
/**
49-
* @param $model
50-
* @param $width
51-
* @param $height
52-
* @return mixed
53-
*/
5432
public function renderFile($model, $width, $height)
5533
{
5634
$image = $this->makeFromPath($width, $height, $model->path);
5735

5836
return $image->response();
5937
}
6038

61-
/**
62-
* @param $width
63-
* @param $height
64-
* @return mixed
65-
*/
6639
public function renderPlaceholder($width, $height)
6740
{
6841
$image = Image::cache(function ($image) use ($width, $height) {
@@ -75,28 +48,6 @@ public function renderPlaceholder($width, $height)
7548
return $image->response();
7649
}
7750

78-
/**
79-
* @param $width
80-
* @param $height
81-
* @param $path
82-
* @return mixed
83-
*/
84-
protected function makeFromPath($width, $height, $path)
85-
{
86-
return Image::cache(function ($image) use ($path, $width, $height) {
87-
$img = $image->make(Storage::get($path));
88-
$this->resize($img, $width, $height);
89-
90-
return $img;
91-
}, 10, true);
92-
}
93-
94-
/**
95-
* @param $img
96-
* @param $width
97-
* @param $height
98-
* @return mixed
99-
*/
10051
protected function resize($img, $width, $height)
10152
{
10253
if (! empty($width) && ! empty($height)) {
@@ -113,4 +64,14 @@ protected function resize($img, $width, $height)
11364

11465
return $img;
11566
}
67+
68+
protected function makeFromPath($width, $height, $path)
69+
{
70+
return Image::cache(function ($image) use ($path, $width, $height) {
71+
$img = $image->make(Storage::get($path));
72+
$this->resize($img, $width, $height);
73+
74+
return $img;
75+
}, 10, true);
76+
}
11677
}

0 commit comments

Comments
 (0)