From 66b12ad7a09bc01a3028ee29502e47db26497710 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 11 Aug 2020 09:30:03 +0200 Subject: [PATCH] Document the inclusing of a composer autoloader Signed-off-by: Christoph Wurst --- developer_manual/app_development/bootstrap.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/developer_manual/app_development/bootstrap.rst b/developer_manual/app_development/bootstrap.rst index db8af43f1..7d279498e 100644 --- a/developer_manual/app_development/bootstrap.rst +++ b/developer_manual/app_development/bootstrap.rst @@ -63,6 +63,9 @@ The class **must** extend ``OCP\AppFramework\App`` and it may optionally impleme public function register(IRegistrationContext $context): void { // ... registration logic goes here ... + // Register the composer autoloader for packages shipped by this app, if applicable + @include_once __DIR__ . '/../../vendor/autoload.php' + $context->registerEventListener( BeforeUserDeletedEvent::class, UserDeletedListener::class @@ -121,7 +124,7 @@ app.php (deprecated) -------------------- Nextcloud will ``require_once`` every installed and enabled app's ``appinfo/app.php`` file if it exists. The app can use -this file to run registrations of services, event listeners and similar. +this file to run registrations of autoloaders, services, event listeners and similar. To leverage the advantages of object-oriented programming, it's recommended to put the logic into an :ref:`Application` class and query an instance like @@ -132,4 +135,7 @@ class and query an instance like declare(strict_types=1); + // Register the composer autoloader for packages shipped by this app, if applicable + @include_once __DIR__ . '/../vendor/autoload.php' + $app = \OC::$server->query(\OCA\MyApp\AppInfo\Application::class);