1

I want to create an API to communicate with a REST Web Service.

For this, I'm building this API as a library. I Just create the folder structure:

├── composer.json
├── LICENSE
├── README.md
└── src
    └── PkgRoot
        └── PkgName
            ├── XXXAPIFactory.php
            ├── XXXAPI.php
            ├── XXXAPIRestImpl.php
            ├── XXXResponse.php
            └── Protocol.php

Now, I'm trying add a configuration for the API-KEY. I believe this should be added in config.yml.

Should I change all these structure the be like a Symfony Bundle? How can I add and register configurations parameters in config.ym?

Victor
  • 8,309
  • 14
  • 80
  • 129

1 Answers1

0

It is not mandatory, but I think that you definitely should. Why aren't you using a Bundle ?

Using a Bundle would permit you, among so many other cool things, to create a friendly configuration as you want.

MeuhMeuh
  • 826
  • 6
  • 26
  • Only bundles accepts configurations parameters? I do not found any architecture guideline for `Symfony2` to explain when use bundle or a simple API. – Victor Jul 28 '15 at 16:38
  • No, you could parse the configuration thanks to the Yaml component for example, but why not using the right tools that Symfony2 is providing if you decided to use the framework ? Do you have any reason why you would not use the Bundle system ? – MeuhMeuh Jul 28 '15 at 16:39
  • No. I'm only trying to undestand what is a Bundle and why I should use bundles. – Victor Jul 28 '15 at 16:52
  • 1
    What is called a "Bundle" is a set of files organized logically and using specific conventions that are defined by the Symfony framework, in order to use the Symfony solution properly. A good example is the one that you just described, with the configuration process. If you look at the link that I gave to you, you should see that ways to parse configuration data are simplified and use Symfony tools. Using Bundles permits you to respect the Symfony Full-stack framework "way" to use its set of tools. – MeuhMeuh Jul 28 '15 at 16:55