PHPackages                             apie/service-provider-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. apie/service-provider-generator

ActiveLibrary

apie/service-provider-generator
===============================

Creates a service provider for Laravel from a Symfony services.yaml

0.14.0(3mo ago)070.7k18MITPHP

Since Sep 9Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/apie-lib/service-provider-generator)[ Packagist](https://packagist.org/packages/apie/service-provider-generator)[ RSS](/packages/apie-service-provider-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (21)Used By (18)

[![](https://raw.githubusercontent.com/apie-lib/apie-lib-monorepo/main/docs/apie-logo.svg)](https://raw.githubusercontent.com/apie-lib/apie-lib-monorepo/main/docs/apie-logo.svg)

ServiceProvider generator
=========================

[](#serviceprovider-generator)

[![Latest Stable Version](https://camo.githubusercontent.com/14ba0612ec50568d8243062b4b90cecaf44dbad4ecfb44b8b6555450b1dc36a3/68747470733a2f2f706f7365722e707567782e6f72672f617069652f736572766963652d70726f76696465722d67656e657261746f722f76)](https://packagist.org/packages/apie/service-provider-generator) [![Total Downloads](https://camo.githubusercontent.com/23f3ef25b80aa226ec67229f6f65f30153b7cb24405ae3069667494b19e47b55/68747470733a2f2f706f7365722e707567782e6f72672f617069652f736572766963652d70726f76696465722d67656e657261746f722f646f776e6c6f616473)](https://packagist.org/packages/apie/service-provider-generator) [![Latest Unstable Version](https://camo.githubusercontent.com/6e2e8d28e1bdf50c267b582576251438361db32fc2c7950fa1c85aa1749ac989/68747470733a2f2f706f7365722e707567782e6f72672f617069652f736572766963652d70726f76696465722d67656e657261746f722f762f756e737461626c65)](https://packagist.org/packages/apie/service-provider-generator) [![License](https://camo.githubusercontent.com/09837cc06ac1a14ed354581f4f9f6e2398951f23fc8dfb601ba4673d19749a96/68747470733a2f2f706f7365722e707567782e6f72672f617069652f736572766963652d70726f76696465722d67656e657261746f722f6c6963656e7365)](https://packagist.org/packages/apie/service-provider-generator) [![PHP Version Require](https://camo.githubusercontent.com/a8934e310f6e1fe65ed775879876dc6464e24a86025561672fcdd4b633d98b58/68747470733a2f2f706f7365722e707567782e6f72672f617069652f736572766963652d70726f76696465722d67656e657261746f722f726571756972652f706870)](https://packagist.org/packages/apie/service-provider-generator) [![Code coverage](https://raw.githubusercontent.com/apie-lib/service-provider-generator/main/coverage_badge.svg)](https://apie-lib.github.io/coverage/service-provider-generator/index.html)

[![PHP Composer](https://github.com/apie-lib/service-provider-generator/actions/workflows/php.yml/badge.svg?event=push)](https://github.com/apie-lib/service-provider-generator/actions/workflows/php.yml)

This package is part of the [Apie](https://github.com/apie-lib) library.

Documentation
-------------

[](#documentation)

One issue with writing framework agnostic code is that most frameworks have different ways to register classes in their service container.

- The Symfony framework works with configuration files, attributes and autowiring.
- Laravel works with autowiring everything or writing PHP code in a ServiceProvider how to instantiate a specific service.

If we want our code to be framework agnostic we need a way to make sure we do not need maintain 2 'service container registries'.

That's where this library comes in. We use the Symfony yaml configuration files as basis and let it generate a ServiceProvider class that Laravel can use. That way we can make our library work effortlessly

### Code usage

[](#code-usage)

The class only creates a string with the source code, you have to manually store it in a file (recommended) or use the 'evil' eval() method.

```
