Bootstrapping app fails for different Nextcloud server versions

Hey,
I’m currently working on an app with following bootstrap code

<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2024 synyx GmbH & Co. KG
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace OCA\Cleanup\AppInfo;

use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;

use Psr\Container\ContainerInterface;
use Throwable;

class Application extends App implements IBootstrap {

	public const APP_ID = 'cleanup';
	public const APP_NAME = 'Cleanup';

	/**
	 * Application constructor.
	 *
	 * @param array $params
	 */
	public function __construct(array $params = []) {
		parent::__construct(self::APP_ID, $params);
	}

	/**
	 * @param IRegistrationContext $context
	 */
	public function register(IRegistrationContext $context): void {
		include_once __DIR__ . '/../../vendor/autoload.php';
	}

	/**
	 * @param IBootContext $context
	 *
	 * @throws Throwable
	 */
	public function boot(IBootContext $context): void {
	}

}

in my composer.json i have this

	"require-dev": {
		"psalm/phar": "^5.26.1",
		"nextcloud/coding-standard": "^1.2",
		"nextcloud/ocp": "dev-stable30"
	},

This works for Nextcloud 30, as soon as I test my app on Nextcloud 29, loading the app fails and breaks the Nextcloud instance. So I have to change the dependency back to dev-stable29.

Is it possible to support all recent Nextcloud versions withtout the need to change the dependency?

Regards
Jonas

Hi @onny,

the nextcloud/ocp package contains a list of classes/interfaces that we consider our “public api”. A common use case for nextcloud/ocp is to run psalm on your ci without having a nextcloud/server checkout.

The mail app also supports multiple nextcloud versions: GitHub - nextcloud/mail: 💌 Mail app for Nextcloud

We don’t have the ocp package in our composer.json. The package is installed when running psalm in the CI workflow: mail/.github/workflows/psalm-matrix.yml at 052a2056bb761996fe7f10ee3ade019132478f65 · nextcloud/mail · GitHub

Is it possible to support all recent Nextcloud versions withtout the need to change the dependency?

tl;dr remove it :wink:

I recommend to setup psalm and phpunit to run the anlysis and tests against all support nextcloud majors.

1 Like

Oh thank you, that solved it for me :+1: