-
Notifications
You must be signed in to change notification settings - Fork 64
Creating an API as a 2nd level namespace #239
Comments
You, "Dr., it hurts when I do this" I prefer to name my 'main' module LikeThis and my API for the 'main api' LikeThisApi. |
@TomHAnderson, I don't follow.You mean "then don't use vendor namespaces"? When you say "I prefer" it means one should be able to choose. Currently, I'm not able to choose. |
The file structure idea you're using of organizing modules as ModuleName/Subpart/src is incorrect. The proper way to handle this is ModuleName/src/ModuleName/Subpart/... An excellent example of doing this is https://github.com/zfcampus/zf-apigility-doctrine where I use two modules in the same project namespace. See the /src directory for the bifurcation. |
See the Recommended Structure for modules here: http://framework.zend.com/manual/2.0/en/modules/zend.module-manager.intro.html Take note there are not multiple instances of a /src directory for a module; just 1. |
@TomHAnderson I'm not suggesting changing the module file structure, there is no "subpart", following your example, the src would be inside VendorName/ModuleName/src The documentation for ZF says "The name of a module in a typical Zend Framework 2 application is simply a PHP namespace and must follow all of the same rules for naming." So, \Vendor\And\Any\Number\Of\Levels\Before\The\Module is a valid namespace. Even Apigility modules are inside the "ZF" vendor namespace ('ZF\Apigility', 'ZF\Apigility\Provider', 'ZF\Apigility\Documentation') If I would like to have both your API and my API modules in the same proyect, it would be possible if they were in a different namespace, like having your's in /modules/TomHAnderson/MyApi and mine at /modules/Str/MyApi. |
Hello, Today I performed some test showing namespaces API modules is possible - as far as I can tell the UI needs to be updated in a few places to support this. Ofcourse this was a quick test so perhaps it is more complicated than it seems. I'm using apigility 1.1.x What I did was create an API called 'MyApi'. Added some REST stuff to it so I know it works, even configured some fields. Then I manually moved the whole modules/MyApi to modules/My/Api and updated every class. Updated the application config to use the namespace module. And updated the configuration files in the MyApi module to reflect these changes. Then I retested the API, which still worked as expected. (yee) I then reloaded the UI and the API showed up as 'My.Api' in the API list. The main settings page of it loaded fine - however accessing any TAB's such as fields gave me an error. The err is that it can't find the API 'My.Api' which could be expected as the endpoints' probably aren't capable of translating 'My.Api' into 'My/Api'. I for one would love to see apigility capable of namespaced API's. |
Hello @basz, I am with the same problem, I did the same thing of you, I created the API and move it to the module, but when I tried create a new service the apigility does not follow the project struct. In my case I need 3rd level namespace: Bellow some examples: Did you found a solution? |
@basz thx for this introspection :D. FYI, I usually have sub namespace (in prod) and there is absolutely no pb (there are tested). So we let the ui down because in fact, it's a discovery tool ^^ :P |
Same issue here 😿 |
This repository has been closed and moved to laminas-api-tools/api-tools-admin; a new issue has been opened at laminas-api-tools/api-tools-admin#40. |
I tried to create an API named "MyVendor\Api" so all files will be created inside the /module/MyVendor/Api/src folder, but calling the API that way, I get the following error message:
name: The API name must be a valid PHP namespace
The text was updated successfully, but these errors were encountered: