-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating an API as a 2nd level namespace #40
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. Originally posted by @TomHAnderson at zfcampus/zf-apigility-admin#239 (comment) |
@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. Originally posted by @str at zfcampus/zf-apigility-admin#239 (comment) |
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. Originally posted by @TomHAnderson at zfcampus/zf-apigility-admin#239 (comment) |
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. Originally posted by @TomHAnderson at zfcampus/zf-apigility-admin#239 (comment) |
@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. Originally posted by @str at zfcampus/zf-apigility-admin#239 (comment) |
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. Originally posted by @basz at zfcampus/zf-apigility-admin#239 (comment) |
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? Originally posted by @viniciusgava at zfcampus/zf-apigility-admin#239 (comment) |
@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 Originally posted by @merlindorin at zfcampus/zf-apigility-admin#239 (comment) |
Same issue here 😿 Originally posted by @snapshotpl at zfcampus/zf-apigility-admin#239 (comment) |
This was very old; 2014. I don't have a strong argument in support of using sub-namespaces for APIs anymore. |
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
Originally posted by @str at zfcampus/zf-apigility-admin#239
The text was updated successfully, but these errors were encountered: