Skip to content
This repository has been archived by the owner on Jan 3, 2020. It is now read-only.

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Faust committed Nov 4, 2016
0 parents commit 38b55dd
Show file tree
Hide file tree
Showing 24 changed files with 907 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
@@ -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
9 changes: 9 additions & 0 deletions .gitattributes
@@ -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
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
composer.lock
phpunit.xml
vendor
3 changes: 3 additions & 0 deletions .styleci.yml
@@ -0,0 +1,3 @@
preset: laravel

linting: true
21 changes: 21 additions & 0 deletions .travis.yml
@@ -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
20 changes: 20 additions & 0 deletions LICENSE
@@ -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.
39 changes: 39 additions & 0 deletions README.md
@@ -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.
51 changes: 51 additions & 0 deletions composer.json
@@ -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
}
28 changes: 28 additions & 0 deletions phpunit.xml.dist
@@ -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>
29 changes: 29 additions & 0 deletions src/Loader/Loader.php
@@ -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);
}
25 changes: 25 additions & 0 deletions src/Loader/RouteLoader.php
@@ -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.');
}
}
24 changes: 24 additions & 0 deletions src/Loader/TranslationLoader.php
@@ -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.');
}
}
24 changes: 24 additions & 0 deletions src/Loader/ViewLoader.php
@@ -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.');
}
}
24 changes: 24 additions & 0 deletions src/Publisher/AssetPublisher.php
@@ -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.');
}
}
42 changes: 42 additions & 0 deletions src/Publisher/ConfigPublisher.php
@@ -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.');
}
}

0 comments on commit 38b55dd

Please sign in to comment.