Skip to content

Commit 4881bc5

Browse files
author
Bradley Weston
authored
Merge pull request #77 from SidharthRaveendran/master
Laravel 5.5 autodiscovery.
2 parents 66b99dd + a7282d4 commit 4881bc5

File tree

4 files changed

+57
-14
lines changed

4 files changed

+57
-14
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ Despite the package name, this package works with Laravel 5.x!
1212

1313
- Class not found errors: https://github.com/anlutro/laravel-settings/issues/38
1414

15-
## Installation
15+
## Installation - Laravel >= 5.5
16+
17+
1. `composer require anlutro/l4-settings`
18+
2. Publish the config file by running `php artisan vendor:publish --provider="anlutro/l4-settings" --tag="config"`. The config file will give you control over which storage engine to use as well as some storage-specific settings.
19+
20+
## Installation - Laravel < 5.5
1621

1722
1. `composer require anlutro/l4-settings`
1823
2. Add `anlutro\LaravelSettings\ServiceProvider` to the array of providers in `config/app.php`.

composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@
2727
"anlutro\\LaravelSettings\\": "src/"
2828
}
2929
},
30+
"extra": {
31+
"laravel": {
32+
"aliases": {
33+
"Setting": "anlutro\\LaravelSettings\\Facade"
34+
},
35+
"providers": [
36+
"anlutro\\LaravelSettings\\ServiceProvider"
37+
]
38+
}
39+
},
3040
"minimum-stability": "dev",
3141
"prefer-stable": true
3242
}

src/ServiceProvider.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ public function register()
5858
*/
5959
public function boot()
6060
{
61-
if (version_compare(Application::VERSION, '5.0', '>=')) {
61+
if (version_compare(Application::VERSION, '5.3', '>=')) {
62+
$this->loadMigrationsFrom(__DIR__.'/migrations');
63+
$this->publishes([
64+
__DIR__.'/config/config.php' => config_path('settings.php')
65+
], 'config');
66+
} else if (version_compare(Application::VERSION, '5.0', '>=')) {
6267
$this->publishes([
6368
__DIR__.'/config/config.php' => config_path('settings.php')
6469
], 'config');

src/config/config.php

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,45 @@
11
<?php
2-
return array(
3-
// which type of store to use.
4-
// valid options: 'json', 'database'
2+
3+
return [
4+
/*
5+
|--------------------------------------------------------------------------
6+
| Default Settings Store
7+
|--------------------------------------------------------------------------
8+
|
9+
| This option controls the default settings store that gets used while
10+
| using this settings library.
11+
|
12+
| Supported: "json", "database"
13+
|
14+
*/
515
'store' => 'json',
616

7-
// if the json store is used, give the full path to the .json file
8-
// that the store writes to.
17+
/*
18+
|--------------------------------------------------------------------------
19+
| JSON Store
20+
|--------------------------------------------------------------------------
21+
|
22+
| If the store is set to "json", settings are stored in the defined
23+
| file path in JSON format. Use full path to file.
24+
|
25+
*/
926
'path' => storage_path().'/settings.json',
1027

11-
// if the database store is used, set the name of the table used..
12-
'table' => 'settings',
13-
14-
// If the database store is used, you can set which connection to use. if
15-
// set to null, the default connection will be used.
28+
/*
29+
|--------------------------------------------------------------------------
30+
| Database Store
31+
|--------------------------------------------------------------------------
32+
|
33+
| The settings are stored in the defined file path in JSON format.
34+
| Use full path to JSON file.
35+
|
36+
*/
37+
// If set to null, the default connection will be used.
1638
'connection' => null,
17-
39+
// Name of the table used.
40+
'table' => 'settings',
1841
// If you want to use custom column names in database store you could
1942
// set them in this configuration
2043
'keyColumn' => 'key',
2144
'valueColumn' => 'value'
22-
);
45+
];

0 commit comments

Comments
 (0)