tjventurini / service-provider
A simple laravel ServiceProvider class for standardized packages.
Installs: 19
Dependents: 2
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
Type:package
Requires (Dev)
- phpunit/phpunit: ^9.5
README
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 😉
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
.
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
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 and Package classes 🕵
Roadmap 🛣
- Autodetect commands
- Autodetect services
- Autodetect graphql namespaces
- Enable handling of multiple configuration files
- Enable handling of multiple graphql schema files