Example
A complete script
Below script boots Joomla and Joomlatools framework, and then runs your custom code. Save its contents into a PHP file and run it from the browser or the command line:
<?php
define('_JEXEC', 1);
define('JPATH_BASE', __DIR__ . '/administrator');
if (file_exists(JPATH_BASE . '/includes/defines.php')) {
include_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_BASE . '/includes/framework.php';
// Instantiate the application.
$app = JFactory::getApplication('administrator');
// Make sure that a user with add permissions is logged in.
$app->login([
'username' => 'admin', // Change the username here
'password' => 'admin' // Change the password here
]);
// Boot Joomlatools Framework
JPluginHelper::importPlugin('system', 'joomlatools');
$document_data = [
'title' => 'title', // The document title.
'docman_category_id' => 1, // The category ID.
'storage_path' => 'path/to/the/file.txt' // part of the path that comes after joomlatools-files/docman-files/
];
$result = Koowa::getObject('com://admin/docman.controller.document')
->add($document_data);