Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tjventurini/service-provider
A simple laravel ServiceProvider class for standardized packages.
https://github.com/tjventurini/service-provider
Last synced: 10 days ago
JSON representation
A simple laravel ServiceProvider class for standardized packages.
- Host: GitHub
- URL: https://github.com/tjventurini/service-provider
- Owner: tjventurini
- License: mit
- Created: 2021-02-07T03:44:24.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-05T23:43:44.000Z (over 3 years ago)
- Last Synced: 2024-04-30T19:03:59.084Z (7 months ago)
- Language: PHP
- Size: 69.3 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Service Provider (BETA)
This package provides a the `SimpleServiceProvider` class that you can use to speed up your laravel package development.
This package was not inspired but highly influenced by [spatie/lravel-package-tools](https://github.com/spatie/laravel-package-tools) 😉
## Installation
To install this package you can run the following.
```
composer require tjventurini/service-provider
```In order to use it in a package you should add it as a dependency in your `composer.json` file.
## Features
* Automatically detect resources provided by your package 🔍
* Can handle and autodetect configuration
* Can handle and autodetect migrations
* Can handle and autodetect translations
* Can handle and autodetect views
* Can handle artisan commands
* Can handle services
* Can handle and autodetect graphql schema
* Can handle graphql namespaces
* Can handle route files## Usage
To use the `SimpleServiceProvider` class just extend it on your `ServiceProvider`.
```php
use Tjventurini\ServiceProvider\SimpleServiceProvider;class YourPackageServiceProvider extends SimpleServiceProvider
```Per default the service provider will try to detect and setup the resources provided by your package without further steps required from you. If you want or need more flexibility for your setup, read on.
## Configuration
```php
use Tjventurini\ServiceProvider\SimpleServiceProvider;class YourPackageServiceProvider extends SimpleServiceProvider
{
/**
* Setup the configuration for the given package.
*
* @param Package $Package
* @return void
*/
public function configurePackage(Package $Package): void
{
$Package
->setPackageSlug('your-package-slug')
->hasConfig()
->hasMigrations()
->hasTranslations()
->hasCommands([
SomeCommand::class,
AnotherCommand::class
])
->hasGraphQLSchema()
->hasGraphQLNamespaces([
'models' => 'Foo\\Bar'
])
->registerService(SomeService::class)
->registerService(ServiceWithConfig::class, ['api_key' => 'some-key'])
->hasWebRoutes()
->hasApiRoutes()
->registerRouteFile('routes/admin.php');
}
}
```For more information check out the [SimpleServiceProvider](src/SimpleServiceProvider.php) and [Package](src/Package.php) classes 🕵
## Roadmap 🛣
* Autodetect commands
* Autodetect services
* Autodetect graphql namespaces
* Enable handling of multiple configuration files
* Enable handling of multiple graphql schema files