Bootstrapping Api 20 composer vendor/autoload.php

Dear,

I have follow this : Bootstrapping — Nextcloud latest Developer Manual latest documentation

so I do that in myapp/lib/AppInfo/Application.php

<?php

//declare(strict_types=1);

namespace OCA\Gestion\AppInfo;

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

class Application extends App implements IBootstrap {

public function __construct() {
    parent::__construct('gestion');
}

public function register(IRegistrationContext $context): void {
    // ... registration logic goes here ...

    // Register the composer autoloader for packages shipped by this app, if applicable
    require_once '/var/www/html/apps/gestion/vendor/autoload.php';
}

public function boot(IBootContext $context): void {
    // ... boot logic goes here ...

    // /** @var IManager $manager */
    // $manager = $context->getAppContainer()->query(IManager::class);
    // $manager->registerNotifierService(Notifier::class);
}

}

I have install :

composer require twbs/bootstrap:5.0.0-beta2

When I try to format a table like that :

 <table class="table-primary">

The format doesn’t applied, I have no error, and the bootstrap.js doesn’t appear in the head of html page.

does I have forget a step ?

The php part with including the 3rdparty lib seems almost alright, what you have to be very careful with is the absolute path (/var/www/…) as that will only work for your environment. Change that to a relative path like include_once __DIR__ . '/../../vendor/autoload.php';.

And including the bootstrap package in php won’t magically load the bootstrap files. You can use the script and style helpers for that. You can either do this in the boot method of the Application class if bootstrap is supposed to be loaded on every Nextcloud page on in your controller method or template if it should be shown there.

See JavaScript — Nextcloud latest Developer Manual latest documentation

Ok thank you, the absolute path was for the night test …

that was the lines I forgot :blush:

 // add vendor files (also allows the array syntax)
vendor_script('myapp', 'script');  //  adds vendor/script.js