Skip to content

Commit 82e671a

Browse files
committed
Re-aligned init files with Laravel default
Removed the custom init elements that we added in 2017 to custom load the helpers file and instead load via composer. Also removed laravel-microscope package due to not running due to helpers file.
1 parent 474770a commit 82e671a

File tree

6 files changed

+23
-53
lines changed

6 files changed

+23
-53
lines changed

app/helpers.php

+6-17
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
/**
99
* Get the path to a versioned file.
10-
*
11-
* @param string $file
12-
* @return string
1310
* @throws Exception
1411
*/
1512
function versioned_asset(string $file = ''): string
@@ -33,7 +30,6 @@ function versioned_asset(string $file = ''): string
3330
/**
3431
* Helper method to get the current User.
3532
* Defaults to public 'Guest' user if not logged in.
36-
* @return User
3733
*/
3834
function user(): User
3935
{
@@ -57,9 +53,8 @@ function hasAppAccess(): bool
5753
}
5854

5955
/**
60-
* Check if the current user has a permission.
61-
* If an ownable element is passed in the jointPermissions are checked against
62-
* that particular item.
56+
* Check if the current user has a permission. If an ownable element
57+
* is passed in the jointPermissions are checked against that particular item.
6358
*/
6459
function userCan(string $permission, Ownable $ownable = null): bool
6560
{
@@ -75,9 +70,6 @@ function userCan(string $permission, Ownable $ownable = null): bool
7570
/**
7671
* Check if the current user has the given permission
7772
* on any item in the system.
78-
* @param string $permission
79-
* @param string|null $entityClass
80-
* @return bool
8173
*/
8274
function userCanOnAny(string $permission, string $entityClass = null): bool
8375
{
@@ -87,27 +79,26 @@ function userCanOnAny(string $permission, string $entityClass = null): bool
8779

8880
/**
8981
* Helper to access system settings.
90-
* @param string $key
91-
* @param $default
9282
* @return bool|string|SettingService
9383
*/
9484
function setting(string $key = null, $default = false)
9585
{
9686
$settingService = resolve(SettingService::class);
87+
9788
if (is_null($key)) {
9889
return $settingService;
9990
}
91+
10092
return $settingService->get($key, $default);
10193
}
10294

10395
/**
10496
* Get a path to a theme resource.
105-
* @param string $path
106-
* @return string
10797
*/
10898
function theme_path(string $path = ''): string
10999
{
110100
$theme = config('view.theme');
101+
111102
if (!$theme) {
112103
return '';
113104
}
@@ -121,9 +112,6 @@ function theme_path(string $path = ''): string
121112
* to the 'resources/assets/icons' folder.
122113
*
123114
* Returns an empty string if icon file not found.
124-
* @param $name
125-
* @param array $attrs
126-
* @return mixed
127115
*/
128116
function icon(string $name, array $attrs = []): string
129117
{
@@ -139,6 +127,7 @@ function icon(string $name, array $attrs = []): string
139127

140128
$iconPath = resource_path('icons/' . $name . '.svg');
141129
$themeIconPath = theme_path('icons/' . $name . '.svg');
130+
142131
if ($themeIconPath && file_exists($themeIconPath)) {
143132
$iconPath = $themeIconPath;
144133
} else if (!file_exists($iconPath)) {

artisan

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ define('LARAVEL_START', microtime(true));
55

66
/*
77
|--------------------------------------------------------------------------
8-
| Initialize The App
8+
| Register The Auto Loader
99
|--------------------------------------------------------------------------
1010
|
11-
| We need to get things going before we start up the app.
12-
| The init file loads everything in, in the correct order.
11+
| Composer provides a convenient, automatically generated class loader
12+
| for our application. We just need to utilize it! We'll require it
13+
| into the script here so that we do not have to worry about the
14+
| loading of any our classes "manually". Feels great to relax.
1315
|
1416
*/
1517

16-
require __DIR__.'/bootstrap/init.php';
18+
require __DIR__.'/vendor/autoload.php';
1719

1820
$app = require_once __DIR__.'/bootstrap/app.php';
1921

bootstrap/init.php

-25
This file was deleted.

composer.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"socialiteproviders/twitch": "^5.0"
3636
},
3737
"require-dev": {
38-
"imanghafoori/laravel-microscope": "^1.0",
3938
"barryvdh/laravel-debugbar": "^3.2.8",
4039
"barryvdh/laravel-ide-helper": "^2.6.4",
4140
"fzaninotto/faker": "^1.4",
@@ -52,7 +51,10 @@
5251
],
5352
"psr-4": {
5453
"BookStack\\": "app/"
55-
}
54+
},
55+
"files": [
56+
"app/helpers.php"
57+
]
5658
},
5759
"autoload-dev": {
5860
"psr-4": {

phpunit.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit backupGlobals="false"
33
backupStaticAttributes="false"
4-
bootstrap="bootstrap/init.php"
4+
bootstrap="vendor/autoload.php"
55
colors="true"
66
convertErrorsToExceptions="true"
77
convertNoticesToExceptions="true"

public/index.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@
1111

1212
/*
1313
|--------------------------------------------------------------------------
14-
| Initialize The App
14+
| Register The Auto Loader
1515
|--------------------------------------------------------------------------
1616
|
17-
| We need to get things going before we start up the app.
18-
| The init file loads everything in, in the correct order.
17+
| Composer provides a convenient, automatically generated class loader for
18+
| our application. We just need to utilize it! We'll simply require it
19+
| into the script here so that we don't have to worry about manual
20+
| loading any of our classes later on. It feels great to relax.
1921
|
2022
*/
2123

22-
require __DIR__.'/../bootstrap/init.php';
24+
require __DIR__.'/../vendor/autoload.php';
2325

2426
/*
2527
|--------------------------------------------------------------------------

0 commit comments

Comments
 (0)