Skip to content

Commit ca1a894

Browse files
Merge pull request #12024 from nextcloud/feat/admin/server-autoloading
feat(admin): Document server autoloading and class maps
2 parents b8a457c + ae9bc1e commit ca1a894

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

Diff for: developer_manual/digging_deeper/classloader.rst

+15-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,22 @@ Classloader
77

88
The classloader is provided by Nextcloud and loads all your classes automatically. See :ref:`the composer section<app-composer>` if you want to include and autoload 3rd party libraries.
99

10+
Server autoloading
11+
------------------
12+
13+
Classes of the Nextcloud server use an authoritative class map, and the class map is committed to git.
14+
15+
When you add, move or delete a class file you have to update the autoloaders for the class to be found. The process is slightly different for classes that belong to the server itself, and apps that are included in the server repository:
16+
17+
1. Use ``composer dump-autoload`` to update the server class map.
18+
2. Use ``composer -d apps/dav/composer dump-autoload`` to update the class map of the dav app. The same applies for all other apps that are part of the server repository.
19+
20+
.. tip:: Use git's `patch option <https://git-scm.com/docs/git-add#Documentation/git-add.txt---patch>`_ when adding autoloader files. It allows you to pick only the lines relevant to the classes you added, moved or deleted. E.g. ``git add -p apps/dav/composer``.
21+
1022
.. _app-psr4-autoloader:
1123

12-
PSR-4 autoloading
13-
-----------------
24+
App autoloading
25+
---------------
1426

1527
Nextcloud uses a :ref:`PSR-4 autoloader<psr4>`. The namespace **\\OCA\\MyApp**
1628
is mapped to :file:`/apps/myapp/lib/`. Afterwards normal PSR-4 rules apply, so
@@ -38,7 +50,7 @@ thereby mapped to :file:`/apps/myapp/tests/`.
3850
.. _app-custom-classloader:
3951

4052
Replacing Nextcloud's autoloader
41-
--------------------------------
53+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4254

4355
Nextcloud's autoloader for apps is flexible and robust but not always the fastest. You can improve the loading speed of your app by shipping and optimizing a Composer class loader with the app.
4456

0 commit comments

Comments
 (0)