Skip to content

Commit 5e8bf69

Browse files
committed
Basic service provider
1 parent b003132 commit 5e8bf69

File tree

4 files changed

+66
-2
lines changed

4 files changed

+66
-2
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "library",
66
"require": {
77
"php": "^7.4",
8-
"laravel/framework": "~8.0"
8+
"laravel/support": "^7.0|^8.0"
99
},
1010
"require-dev": {
1111
"orchestra/testbench": "^5.2",
@@ -32,6 +32,7 @@
3232
"extra": {
3333
"laravel": {
3434
"providers": [
35+
"Soved\\Laravel\\Snapshot\\SnapshotServiceProvider"
3536
]
3637
}
3738
}

config/snapshot.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
return [];

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
## Requirements
77

88
- PHP >= 7.4
9-
- Laravel >= 8.0
9+
- Laravel >= 7.0
1010

1111
## Security Vulnerabilities
1212

src/SnapshotServiceProvider.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
namespace Soved\Laravel\Snapshot;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
use Laravel\Lumen\Application as LumenApplication;
7+
use Illuminate\Foundation\Application as LaravelApplication;
8+
9+
class SnapshotServiceProvider extends ServiceProvider
10+
{
11+
/**
12+
* Bootstrap the application services.
13+
*
14+
* @return void
15+
*/
16+
public function boot()
17+
{
18+
}
19+
20+
/**
21+
* Register the application services.
22+
*
23+
* @return void
24+
*/
25+
public function register()
26+
{
27+
$this->configure();
28+
$this->offerPublishing();
29+
}
30+
31+
/**
32+
* Setup the configuration.
33+
*
34+
* @return void
35+
*/
36+
protected function configure()
37+
{
38+
$source = realpath($raw = __DIR__.'/../config/snapshot.php') ?: $raw;
39+
40+
if ($this->app instanceof LumenApplication) {
41+
$this->app->configure('snapshot');
42+
}
43+
44+
$this->mergeConfigFrom($source, 'snapshot');
45+
}
46+
47+
/**
48+
* Setup the resource publishing groups.
49+
*
50+
* @return void
51+
*/
52+
protected function offerPublishing()
53+
{
54+
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
55+
$this->publishes([
56+
__DIR__.'/../config/snapshot.php' => config_path('snapshot.php'),
57+
], 'snapshot-config');
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)