Need to implement IBootstrap in Application to use Middleware?

Hi everyone :slight_smile:

A coworker reported a problem with our Workspace application.

In fact, when we execute a controller method (page#index, group#create and so on.), no middleware is triggered.

I read the documentation and I saw in an example we need to implement the IBootstrap interface in the Application class from Nextcloud 25 : Middlewares β€” Nextcloud latest Developer Manual latest documentation .

I wrote this code :

<?php

namespace OCA\Workspace\AppInfo;

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

class Application extends App implements IBootstrap {

	// code

	public function boot(IBootContext $contexte): void {
	}
}

Then, my middleware work!

I’m sure my problem comes from IBootstrap.
Furthermore, the Nextcloud 24 documentation doesn’t mention IBootstrap in Application : Middlewares β€” Nextcloud latest Developer Manual latest documentation .

If that 's where my problem comes from the implementation of IBootstrap, why is not mention in the upgrade guideline : https://docs.nextcloud.com/server/latest/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_25.html ?

Is it an omission? If yes, I could create a PR to fill the documentation ?

The pull request Create the register function by zak39 Β· Pull Request #649 Β· arawa/workspace Β· GitHub broke it.

With IBootstrap

Services and Middlewares are registered in the register function.

Without IBoostrap

Services and Middlewares are registered in the class constructor.

Relevant documentation

2 Likes

Oooh okay, I missed something I think :thinking:

But, I don’t think it’s explicit enough or is it just me?

We are always happy about pull requests for our documentation!

1 Like

Cool, I will create a PR for this subject :slight_smile: