.. _appclassloader: =========== Classloader =========== .. sectionauthor:: Bernhard Posselt The classloader is provided by Nextcloud and loads all your classes automatically. See :ref:`the composer section` if you want to include and autoload 3rd party libraries. PSR-4 autoloading ----------------- Nextcloud uses a PSR-4 autoloader. The namespace **\\OCA\\MyApp** is mapped to :file:`/apps/myapp/lib/`. Afterwards normal PSR-4 rules apply, so a folder is a namespace section in the same casing and the class name matches the file name. If your appid can not be turned into the namespace by uppercasing the first character, you can specify it in your **appinfo/info.xml** by providing a field called **namespace**. The required namespace is the one which comes after the top level namespace **OCA\\**, e.g.: for **OCA\\MyBeautifulApp\\Some\\OtherClass** the needed namespace would be **MyBeautifulApp** and would be added to the info.xml in the following way: .. code-block:: xml MyBeautifulApp A second PSR-4 root is available when running tests. **\\OCA\\MyApp\\Tests** is thereby mapped to :file:`/apps/myapp/tests/`.