This repository has been archived by the owner on Jan 3, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Brian Faust
committed
Nov 4, 2016
0 parents
commit 38b55dd
Showing
24 changed files
with
907 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
; This file is for unifying the coding style for different editors and IDEs. | ||
; More information at http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.yml] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
* text=auto | ||
|
||
/tests export-ignore | ||
/.editorconfig export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.travis.yml export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/README.md export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
composer.lock | ||
phpunit.xml | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
preset: laravel | ||
|
||
linting: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
language: php | ||
|
||
php: | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
- hhvm | ||
|
||
sudo: false | ||
|
||
before_script: | ||
- travis_retry composer self-update | ||
- travis_retry composer update --no-interaction --prefer-source | ||
|
||
script: | ||
- if [ "$TRAVIS_PHP_VERSION" != "5.6" ]; then vendor/bin/phpunit; fi | ||
- if [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then vendor/bin/phpunit --coverage-clover build/logs/clover.xml; fi | ||
|
||
after_script: | ||
- if [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi | ||
- if [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Brian Faust <hello@brianfaust.de> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Laravel Service Provider | ||
|
||
## Installation | ||
|
||
Require this package, with [Composer](https://getcomposer.org/), in the root directory of your project. | ||
|
||
``` bash | ||
$ composer require faustbrian/laravel-service-provider | ||
``` | ||
|
||
## Usage | ||
|
||
``` php | ||
<?php | ||
|
||
namespace Vendor\Package; | ||
|
||
class ServiceProvider extends \BrianFaust\ServiceProvider\ServiceProvider | ||
{ | ||
public function boot() | ||
{ | ||
$this->publishMigrations() | ||
$this->publishConfig() | ||
$this->publishViews() | ||
$this->publishAssets() | ||
$this->loadViews() | ||
$this->loadTranslations() | ||
$this->mergeConfig('); | ||
} | ||
} | ||
``` | ||
|
||
## Security | ||
|
||
If you discover a security vulnerability within this package, please send an e-mail to Brian Faust at hello@brianfaust.de. All security vulnerabilities will be promptly addressed. | ||
|
||
## License | ||
|
||
The [The MIT License (MIT)](LICENSE). Please check the [LICENSE](LICENSE) file for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"name": "faustbrian/laravel-service-provider", | ||
"description": "DRY Service Provider for Laravel 5 Packages", | ||
"keywords": [ | ||
"laravel", | ||
"framework", | ||
"Laravel-messageable", | ||
"Laravel Messageable", | ||
"Brian Faust", | ||
"faustbrian", | ||
"laravel-service-provider" | ||
], | ||
"license": "MIT", | ||
"authors": [{ | ||
"name": "Brian Faust", | ||
"email": "hello@brianfaust.de", | ||
"homepage": "https://brianfaust.de", | ||
"role": "Developer" | ||
}], | ||
"require": { | ||
"php": "^5.6 || ^7.0", | ||
"illuminate/support": "5.1.* || 5.2.* || 5.3.*" | ||
}, | ||
"require-dev": { | ||
"graham-campbell/testbench": "^3.1", | ||
"mockery/mockery": "^0.9.4", | ||
"phpunit/phpunit": "^5.0", | ||
"scrutinizer/ocular": "~1.1", | ||
"squizlabs/php_codesniffer": "~2.3" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"BrianFaust\\ServiceProvider\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"BrianFaust\\Tests\\ServiceProvider\\": "tests" | ||
} | ||
}, | ||
"config": { | ||
"preferred-install": "dist" | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.0-dev" | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
beStrictAboutTestsThatDoNotTestAnything="true" | ||
beStrictAboutOutputDuringTests="true" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
failOnRisky="true" | ||
failOnWarning="true" | ||
processIsolation="false" | ||
stopOnError="false" | ||
stopOnFailure="false" | ||
verbose="true" | ||
> | ||
<testsuites> | ||
<testsuite name=":vendor Test Suite"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">src/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace BrianFaust\ServiceProvider\Loader; | ||
|
||
use Illuminate\Filesystem\Filesystem; | ||
|
||
abstract class Loader | ||
{ | ||
protected $files; | ||
|
||
protected $packagePath; | ||
|
||
public function __construct(Filesystem $files) | ||
{ | ||
$this->files = $files; | ||
} | ||
|
||
public function getFileList($package) | ||
{ | ||
return $this->getSource($package, $this->packagePath); | ||
} | ||
|
||
public function setPackagePath($packagePath) | ||
{ | ||
$this->packagePath = $packagePath; | ||
} | ||
|
||
abstract protected function getSource($packagePath); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace BrianFaust\ServiceProvider\Loader; | ||
|
||
use InvalidArgumentException; | ||
|
||
class RouteLoader extends Loader | ||
{ | ||
protected function getSource($packagePath) | ||
{ | ||
$sources = [ | ||
"{$packagePath}/resources/routes.php", | ||
"{$packagePath}/src/Http/routes.php", | ||
"{$packagePath}/src/routes.php", | ||
]; | ||
|
||
foreach ($sources as $source) { | ||
if ($this->files->isFile($source)) { | ||
return $source; | ||
} | ||
} | ||
|
||
throw new InvalidArgumentException('Routes not found.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace BrianFaust\ServiceProvider\Loader; | ||
|
||
use InvalidArgumentException; | ||
|
||
class TranslationLoader extends Loader | ||
{ | ||
protected function getSource($packagePath) | ||
{ | ||
$sources = [ | ||
"{$packagePath}/resources/lang", | ||
"{$packagePath}/lang", | ||
]; | ||
|
||
foreach ($sources as $source) { | ||
if ($this->files->isDirectory($source)) { | ||
return $source; | ||
} | ||
} | ||
|
||
throw new InvalidArgumentException('Translations not found.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace BrianFaust\ServiceProvider\Loader; | ||
|
||
use InvalidArgumentException; | ||
|
||
class ViewLoader extends Loader | ||
{ | ||
protected function getSource($packagePath) | ||
{ | ||
$sources = [ | ||
"{$packagePath}/resources/views", | ||
"{$packagePath}/views", | ||
]; | ||
|
||
foreach ($sources as $source) { | ||
if ($this->files->isDirectory($source)) { | ||
return $source; | ||
} | ||
} | ||
|
||
throw new InvalidArgumentException('Views not found.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace BrianFaust\ServiceProvider\Publisher; | ||
|
||
use InvalidArgumentException; | ||
|
||
class AssetPublisher extends Publisher | ||
{ | ||
protected function getSource($packagePath) | ||
{ | ||
$sources = [ | ||
"{$packagePath}/resources/public", | ||
"{$packagePath}/public", | ||
]; | ||
|
||
foreach ($sources as $source) { | ||
if ($this->files->isDirectory($source)) { | ||
return [$source => $this->publishPath]; | ||
} | ||
} | ||
|
||
throw new InvalidArgumentException('Assets not found.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace BrianFaust\ServiceProvider\Publisher; | ||
|
||
use InvalidArgumentException; | ||
|
||
class ConfigPublisher extends Publisher | ||
{ | ||
protected function getSource($packagePath) | ||
{ | ||
$sources = [ | ||
"{$packagePath}/resources/config", | ||
"{$packagePath}/config", | ||
]; | ||
|
||
// iterate through all possible locations | ||
foreach ($sources as $source) { | ||
if ($this->files->isDirectory($source)) { | ||
$paths = []; | ||
|
||
// get all files of the current directory | ||
$files = $this->getSourceFiles($source); | ||
|
||
// iterate through all files | ||
foreach ($files as $file) { | ||
$destinationPath = $this->getDestinationPath('config', [ | ||
$this->getFileName($file), | ||
]); | ||
|
||
// if the destination doesn't exist we can add the file to the queue | ||
if (!$this->files->exists($destinationPath)) { | ||
$paths[$file] = $destinationPath; | ||
} | ||
} | ||
|
||
return $paths; | ||
} | ||
} | ||
|
||
throw new InvalidArgumentException('Configuration not found.'); | ||
} | ||
} |
Oops, something went wrong.