mirror of
https://github.com/nextcloud/documentation.git
synced 2025-10-26 11:18:02 +00:00
Merge pull request #2909 from nextcloud/enhancement/bootstrapping-autoloader
Document the inclusing of a composer autoloader
This commit is contained in:
commit
501a0fb2e7
@ -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<application-php>`
|
||||
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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user