#!/usr/bin/env php setName('FOSSBilling'); $application->setVersion($di['mod_service']('system')->getVersion()); $modules = $di['mod']('extension')->getCoreModules(); // Check if the config file exists. If it does, the database is likely already initialized and this will work. if ($filesystem->exists(PATH_CONFIG)) { // Try to load the modules from the database. If this fails, the database might not initialized yet. We will use the list of the core modules instead. try { $modules = $di['mod_service']('extension')->getCoreAndActiveModules(); } catch (Exception) { // Do nothing } } // Dynamically load the commands from the modules foreach ($modules as $module) { // Our manifests declare the names in lowercase, but the module directories start with an uppercase letter. $cap = ucfirst((string) $module); $commandsPath = Path::join(PATH_ROOT, 'modules', $cap, 'Commands'); // Skip if Commands directory doesn't exist if (!$filesystem->exists($commandsPath)) { continue; } $finder = new Finder(); $finder->files()->in($commandsPath)->name('*.php'); foreach ($finder as $file) { $command = $file->getFilenameWithoutExtension(); $class = "Box\\Mod\\{$cap}\\Commands\\{$command}"; $command = new $class(); $command->setDi($di); $application->addCommand($command); } } $application->run();