Skip to content

Commit 8f6c36a

Browse files
author
Taras Viyatyk
authored
Merge pull request #305 from dreamfactorysoftware/laravel-upgrade
Add Laravel 6 support
2 parents cd4387a + 2475dfc commit 8f6c36a

Some content is hidden

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

47 files changed

+2410
-1391
lines changed

.env-dist

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@
99
## Application Settings
1010
##------------------------------------------------------------------------------
1111

12+
##You can configure the asset URL host by setting the ASSET_URL variable in your .env file.
13+
##This can be useful if you host your assets on an external service like Amazon S3:
14+
#ASSET_URL=
15+
##This option determines where all the compiled Blade templates will be
16+
##stored for your application. By default, this is within the storage
17+
##directory. However, as usual, you are free to change this value.
18+
#VIEW_COMPILED_PATH=
19+
##Here you may specify the configuration options that should be used when
20+
##passwords are hashed using the Bcrypt algorithm. This will allow you
21+
##to control the amount of time it takes to hash the given password.
22+
#BCRYPT_ROUNDS=
1223
## Application name used in email templates and other displays
1324
#APP_NAME=DreamFactory
1425
## Encryption cipher options are AES-128-CBC or AES-256-CBC (default)
@@ -20,8 +31,8 @@ APP_ENV=local
2031
## Use 'php artisan key:generate' to generate a new key. Key size must be 16, 24 or 32.
2132
APP_KEY=
2233
#APP_LOCALE=en
23-
## LOG setting. Where and/or how the log file is setup. Options are single (default), daily, syslog, errorlog
24-
#APP_LOG=single
34+
## Here you may configure the log channels for your application. Options are stack (default), slack, single, daily, syslog, errorlog
35+
#LOG_CHANNEL=stack
2536
## LOG Level. This is hierarchical and goes in the following order.
2637
## DEBUG -> INFO -> NOTICE -> WARNING -> ERROR -> CRITICAL -> ALERT -> EMERGENCY
2738
## If you set log level to WARNING then all WARNING, ERROR, CRITICAL, ALERT, and EMERGENCY
@@ -75,8 +86,8 @@ APP_KEY=
7586

7687
## CACHE_DRIVER options: apc, array, database, file, memcached, redis
7788
#CACHE_DRIVER=file
78-
## Cache TTL in minutes
79-
#CACHE_DEFAULT_TTL=300
89+
## Cache TTL in seconds
90+
#CACHE_DEFAULT_TTL=18000
8091
## Prefix added to all caching from this installation
8192
#CACHE_PREFIX=dreamfactory
8293
## Database cache settings if CACHE_DRIVER=file
@@ -123,22 +134,22 @@ APP_KEY=
123134
## Queuing Settings
124135
##------------------------------------------------------------------------------
125136

126-
## QUEUE_DRIVER options: sync (default), database, beanstalkd, sqs, redis, null
127-
#QUEUE_DRIVER=sync
137+
## QUEUE_CONNECTION options: sync (default), database, beanstalkd, sqs, redis, null
138+
#QUEUE_CONNECTION=sync
128139
## Name of the queue to use
129140
#QUEUE_NAME=default
130141
## Number of seconds after to retry a failed job
131142
#QUEUE_RETRY_AFTER=90
132-
## If QUEUE_DRIVER = database
143+
## If QUEUE_CONNECTION = database
133144
#QUEUE_TABLE=jobs
134-
## If QUEUE_DRIVER = sqs
135-
#SQS_KEY=
136-
#SQS_SECRET=
137-
#SQS_REGION=us-east-1
145+
## If QUEUE_CONNECTION = sqs
146+
#AWS_ACCESS_KEY_ID=
147+
#AWS_SECRET_ACCESS_KEY=
148+
#AWS_DEFAULT_REGION=us-east-1
138149
#SQS_PREFIX=https://sqs.us-east-1.amazonaws.com/your-account-id
139-
## If QUEUE_DRIVER = beanstalkd or redis
150+
## If QUEUE_CONNECTION = beanstalkd or redis
140151
#QUEUE_HOST=
141-
## If QUEUE_DRIVER = redis
152+
## If QUEUE_CONNECTION = redis
142153
#QUEUE_PORT=6379
143154
#QUEUE_DATABASE=3
144155
#QUEUE_PASSWORD=
@@ -180,8 +191,8 @@ APP_KEY=
180191
## New user confirmation code length. Max/Default is 32. Minimum is 5.
181192
#DF_CONFIRM_CODE_LENGTH=32
182193

183-
## Confirmation code expiration. Default is 1440 minutes (24 hours)
184-
#DF_CONFIRM_CODE_TTL=1440
194+
## Confirmation code expiration. Default is 86400 seconds (24 hours)
195+
#DF_CONFIRM_CODE_TTL=86400
185196

186197
## JSON Web Token session management, encryption secret, defaults to APP_KEY value
187198
#JWT_SECRET=

app/Http/Controllers/Auth/RegisterController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
namespace DreamFactory\Http\Controllers\Auth;
44

5-
use DreamFactory\User;
65
use DreamFactory\Http\Controllers\Controller;
7-
use Illuminate\Support\Facades\Validator;
6+
use DreamFactory\User;
87
use Illuminate\Foundation\Auth\RegistersUsers;
8+
use Illuminate\Support\Facades\Hash;
9+
use Illuminate\Support\Facades\Validator;
910

1011
class RegisterController extends Controller
1112
{
@@ -65,7 +66,7 @@ protected function create(array $data)
6566
return User::create([
6667
'name' => $data['name'],
6768
'email' => $data['email'],
68-
'password' => bcrypt($data['password']),
69+
'password' => Hash::make($data['password']),
6970
]);
7071
}
7172
}

app/Http/Controllers/Controller.php

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

33
namespace DreamFactory\Http\Controllers;
44

5+
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
56
use Illuminate\Foundation\Bus\DispatchesJobs;
6-
use Illuminate\Routing\Controller as BaseController;
77
use Illuminate\Foundation\Validation\ValidatesRequests;
8-
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
8+
use Illuminate\Routing\Controller as BaseController;
99

1010
class Controller extends BaseController
1111
{

app/Http/Controllers/SplashController.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
namespace DreamFactory\Http\Controllers;
44

5+
use DreamFactory\Core\Enums\Verbs;
56
use DreamFactory\Core\Models\User;
67
use DreamFactory\Core\Utility\Session;
7-
use DreamFactory\Core\Enums\Verbs;
8+
use Illuminate\Support\Arr;
89
use Response;
910

1011
class SplashController extends Controller
@@ -18,21 +19,21 @@ public function index()
1819
{
1920
$token = \Request::input('session_token');
2021
$param = '';
21-
if (!empty($token)) {
22-
$param = '?session_token=' . $token;
22+
if (! empty($token)) {
23+
$param = '?session_token='.$token;
2324
}
2425

25-
return redirect(config('df.landing_page', '/test_rest.html') . $param);
26+
return redirect(config('df.landing_page', '/test_rest.html').$param);
2627
}
2728

2829
public function createFirstUser()
2930
{
30-
if (!User::adminExists()) {
31+
if (! User::adminExists()) {
3132
$request = \Request::instance();
3233
$method = $request->method();
3334
$data = [
3435
'username_placeholder' => 'Username (Optional, defaults to email address)',
35-
'email_placeholder' => 'Email Address (Required for login)'
36+
'email_placeholder' => 'Email Address (Required for login)',
3637
];
3738
$loginAttribute = strtolower(config('df.login_attribute', 'email'));
3839
if ($loginAttribute === 'username') {
@@ -48,28 +49,28 @@ public function createFirstUser()
4849
'first_name' => '',
4950
'last_name' => '',
5051
'username' => '',
51-
'errors' => []
52+
'errors' => [],
5253
], $data);
5354

5455
return view('firstUser', $data);
5556
} elseif (Verbs::POST === $method) {
5657
$data = array_merge($request->all(), $data);
5758
$user = User::createFirstAdmin($data);
5859

59-
if (!$user) {
60+
if (! $user) {
6061
return view('firstUser', $data);
6162
}
6263

6364
$jwt = null;
6465
if (true === $login = Session::setUserInfoWithJWT($user)) {
6566
$sessionInfo = Session::getPublicInfo();
66-
$jwt = array_get($sessionInfo, 'session_token');
67+
$jwt = Arr::get($sessionInfo, 'session_token');
6768
}
6869
}
6970
}
7071

71-
if (!empty($jwt)) {
72-
return redirect()->to('/?session_token=' . $jwt);
72+
if (! empty($jwt)) {
73+
return redirect()->to('/?session_token='.$jwt);
7374
} else {
7475
return redirect()->to('/');
7576
}
@@ -88,12 +89,12 @@ public function setupDb()
8889

8990
if (Verbs::GET === $method) {
9091
return view('setup', [
91-
'version' => config('app.version')
92+
'version' => config('app.version'),
9293
]);
9394
} elseif (Verbs::POST === $method) {
9495
try {
9596
if (\Cache::pull('setup_db', false)) {
96-
if (!file_exists(base_path('.env'))) {
97+
if (! file_exists(base_path('.env'))) {
9798
copy(base_path('.env-dist'), base_path('.env'));
9899
}
99100

@@ -113,7 +114,7 @@ public function setupDb()
113114
if ($request->ajax()) {
114115
return json_encode([
115116
'success' => false,
116-
'message' => 'Setup not required. System is already setup'
117+
'message' => 'Setup not required. System is already setup',
117118
]);
118119
}
119120
}
@@ -125,7 +126,7 @@ public function setupDb()
125126
'errors.generic',
126127
[
127128
'error' => $e->getMessage(),
128-
'version' => config('app.version')
129+
'version' => config('app.version'),
129130
]
130131
);
131132
}
@@ -135,4 +136,4 @@ public function setupDb()
135136

136137
return redirect()->to('/');
137138
}
138-
}
139+
}

app/Http/Kernel.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Kernel extends HttpKernel
1515
*/
1616
protected $middleware = [
1717
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
18-
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class
18+
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
1919
];
2020

2121
/**
@@ -26,8 +26,8 @@ class Kernel extends HttpKernel
2626
protected $middlewareGroups = [
2727
'web' => [
2828
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
29-
\Illuminate\Routing\Middleware\SubstituteBindings::class
30-
]
29+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
30+
],
3131
];
3232

3333
/**
@@ -38,6 +38,23 @@ class Kernel extends HttpKernel
3838
* @var array
3939
*/
4040
protected $routeMiddleware = [
41-
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class
41+
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
42+
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
43+
];
44+
45+
/**
46+
* The priority-sorted list of middleware.
47+
*
48+
* This forces non-global middleware to always be in the given order.
49+
*
50+
* @var array
51+
*/
52+
protected $middlewarePriority = [
53+
\Illuminate\Session\Middleware\StartSession::class,
54+
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
55+
\DreamFactory\Http\Middleware\Authenticate::class,
56+
\Illuminate\Session\Middleware\AuthenticateSession::class,
57+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
58+
\Illuminate\Auth\Middleware\Authorize::class,
4259
];
4360
}

app/Providers/AppServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace DreamFactory\Providers;
34

45
use Illuminate\Support\ServiceProvider;

app/Providers/AuthServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class AuthServiceProvider extends ServiceProvider
1212
* @var array
1313
*/
1414
protected $policies = [
15-
'App\Model' => 'App\Policies\ModelPolicy',
15+
'DreamFactory\Model' => 'DreamFactory\Policies\ModelPolicy',
1616
];
1717

1818
/**

app/Providers/EventServiceProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace DreamFactory\Providers;
44

5-
use Illuminate\Support\Facades\Event;
65
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
6+
use Illuminate\Support\Facades\Event;
77

88
class EventServiceProvider extends ServiceProvider
99
{
@@ -13,8 +13,8 @@ class EventServiceProvider extends ServiceProvider
1313
* @var array
1414
*/
1515
protected $listen = [
16-
'App\Events\Event' => [
17-
'App\Listeners\EventListener',
16+
'DreamFactory\Events\Event' => [
17+
'DreamFactory\Listeners\EventListener',
1818
],
1919
];
2020

app/Providers/RouteServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace DreamFactory\Providers;
44

5-
use Illuminate\Support\Facades\Route;
65
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
6+
use Illuminate\Support\Facades\Route;
77

88
class RouteServiceProvider extends ServiceProvider
99
{

app/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace DreamFactory;
44

5-
use Illuminate\Notifications\Notifiable;
65
use Illuminate\Foundation\Auth\User as Authenticatable;
6+
use Illuminate\Notifications\Notifiable;
77

88
class User extends Authenticatable
99
{

bootstrap/app.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
|
1212
*/
1313

14-
use DreamFactory\Core\LogHandlers\StreamHandler;
15-
use DreamFactory\Core\LogHandlers\SyslogHandler;
16-
use DreamFactory\Core\LogHandlers\ErrorLogHandler;
17-
use DreamFactory\Core\LogHandlers\RotatingFileHandler;
18-
use Monolog\Formatter\LineFormatter;
1914
use Monolog\Logger;
2015

2116
$app = new Illuminate\Foundation\Application(
@@ -48,30 +43,6 @@
4843
DreamFactory\Exceptions\Handler::class
4944
);
5045

51-
$app->configureMonologUsing(function (Logger $monolog){
52-
$logFile =
53-
env('DF_MANAGED_LOG_PATH', storage_path('logs')) .
54-
DIRECTORY_SEPARATOR .
55-
env('DF_MANAGED_LOG_FILE', 'dreamfactory.log');
56-
57-
$mode = config('app.log');
58-
59-
if ($mode === 'syslog') {
60-
$monolog->pushHandler(new SyslogHandler('dreamfactory'));
61-
} else {
62-
if ($mode === 'single') {
63-
$handler = new StreamHandler($logFile);
64-
} else if ($mode === 'errorlog') {
65-
$handler = new ErrorLogHandler();
66-
} else {
67-
$handler = new RotatingFileHandler($logFile, 5);
68-
}
69-
70-
$monolog->pushHandler($handler);
71-
$handler->setFormatter(new LineFormatter(null, null, true, true));
72-
}
73-
});
74-
7546
/*
7647
|--------------------------------------------------------------------------
7748
| Return The Application

0 commit comments

Comments
 (0)