-
Couldn't load subscription status.
- Fork 39
Added information #145
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
base: master
Are you sure you want to change the base?
Added information #145
Changes from 6 commits
17cc55c
62bfa21
9bc04d0
e014505
294fd15
011b1a2
4a64691
a163ac8
88864f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "esbonio.sphinx.confDir": "" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,9 @@ Guidelines | |
| Directories structure | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| PRE GLPI 10 | ||
| ++++++++++ | ||
|
|
||
|
Comment on lines
+9
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This entire paragraph must be removed if it's indeed related to versions prior to GLPI v10. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ping. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change currently only adds the label. You want me to drop the paragraph or just accept this change from someone else? But considering my recent rewrite i think it needs a rewrite for glpi11 as well 😅 In that regard, What are the (structuring) rules regarding documenting for various versions. With GLPI11 alot is changing in regards to the folder structure (dropping marketplace, no more front (if done right), etc) Should the convention documentation only describe the latest (x) versions, only the supported versions, all versions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Developers documentation currently only targets GLPI v11. Changes made in v11 can be marked with a |
||
| Real structure will depend of what your plugin propose. See :doc:`requirements <requirements>` to find out what is needed. You may also want to :ref:`take a look at GLPI File Hierarchy Standard <fhs>`. | ||
|
|
||
| .. warning:: | ||
|
|
@@ -50,12 +53,80 @@ The plugin directory structure should look like the following: | |
| * `MyPlugin.xml` and `MyPlugin.png` can be used to reference your plugin on the `plugins directory website <http://plugins.glpi-project.org>`_, | ||
| * the required `setup.php` and `hook.php` files. | ||
|
|
||
| POST GLPI 10 | ||
| +++++++++++ | ||
|
|
||
| In GLPI 10 and newer installations you are adviced to use namespaces and composer autoloader. Objectfiles using namespaces are no longer loaded by the old autoload.function.php but by the newer Composer autoloader. In order to use the composer autoloader in your plugin must place your classfiles in the `/src` directory instead of the `/inc`. In this scenario the `/inc` directory should no longer be present in the plugin folder structure. | ||
DonutsNL marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| The the convention to be used is (Case sensitive): `namespace GlpiPlugin\Myplugin;`. The namespace should be added to every classfile in the `/src` directory and should be PHP convention be placed in the top of your classfile. Classfiles using the `GlpiPlugin\Myplugin\` namespaces will be loaded from: `GLPI_ROOT\Plugins\myplugin\src\ClassName.php`. To include folders inside the `/src` directory simply add them to your namespace and use keywords i.e. `namespace GlpiPlugin\Myplugin\SubFolder\` will load `GLPI_ROOT\Plugins\myplugin\src\SubFolder\ClassName.php`. | ||
DonutsNL marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| +-------------+------------------------------------------------------------+ | ||
| | Directive | Composer mapping | | ||
| +=============+============================================================+ | ||
| | \GlpiPlugin | maps to /plugins or /marketplace | | ||
| +-------------+------------------------------------------------------------+ | ||
| | \MyPlugin | maps to: /myplugin/src converted strtolower | | ||
| +-------------+------------------------------------------------------------+ | ||
| | \SubFolder | maps to /src/SubFolder/ using provided case | | ||
| +-------------+------------------------------------------------------------+ | ||
| | \ClassName | maps to ../ClassName.php using provided case apending .php | | ||
| +-------------+------------------------------------------------------------+ | ||
|
|
||
|
|
||
| GLPI_ROOT/marketplace/myplugin/src/Test.php | ||
|
|
||
| .. code-block:: php | ||
|
|
||
| <?php | ||
|
|
||
| namespace GlpiPlugin\MyPlugin; | ||
|
|
||
| class Test extends CommonDBTM | ||
| { | ||
| \\ Your class code... | ||
| } | ||
|
|
||
| ?> | ||
|
|
||
| GLPI_ROOT/marketplace/myplugin/src/ChildClass/ResultOutcomes.php | ||
|
|
||
| .. code-block:: php | ||
|
|
||
| <?php | ||
|
|
||
| namespace GlpiPlugin\MyPlugin\ChildClass; | ||
|
|
||
| class ResultOutcomes extends CommonDBTM | ||
| { | ||
| \\ Your class code... | ||
| } | ||
|
|
||
| ?> | ||
|
|
||
| GLPI_ROOT/marketplace/myplugin/setup.php | ||
|
|
||
| .. code-block:: php | ||
|
|
||
| <?php | ||
|
|
||
| use GlpiPlugin\MyPlugin\Test; | ||
| use GlpiPlugin\Myplugin\ChildClass\ResultOutcomes; | ||
|
|
||
| function usingTest() : void | ||
| { | ||
| $t = new Test(); | ||
| $r = new ResultOutcomes(); | ||
| } | ||
|
|
||
| ?> | ||
|
|
||
|
|
||
| Where to write files? | ||
| +++++++++++++++++++++ | ||
|
|
||
| .. warning:: | ||
|
|
||
| Plugins my never ask user to give them write access on their own directory! | ||
| Plugins may never ask user to give them write access on their own directory! | ||
|
|
||
| The GLPI installation already ask for administrator to get write access on its ``files`` directory; just use ``GLPI_PLUGIN_DOC_DIR/{plugin_name}`` (that would resolve to ``glpi_dir/files/_plugins/{plugin_name}`` in default basic installations). | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to add .vscode to .gitignore obviously xD sorry.