Conversation
Member
Author
|
In the future, I might implement commands for modules. Modules would be able to define their own commands. Would be great for extensibility and maintainability. Edit: In fact it would be better to do it before merging this and creating a whole new directory under /library. |
Member
Author
b08f65b to
b94d932
Compare
Member
|
@evrifaessa any plans to get this to a mergeable state? |
|
I think this is really old Few suggestion <?php
if (php_sapi_name() !== 'cli') {
die('This script can only be run from the command line.');
}
require_once __DIR__.'/load.php';
$di = include __DIR__.'/di.php';
$di['translate']();
$di->register(new \CristianG\PimpleConsole\ServiceProvider(), [
/**
* Set the console application name. Defaults to 'Console'
* @param string
*/
'console.name' => 'FossBilling Console Commands',
/**
* Set the console application version. Defaults to '1.0'
* @param string
*/
'console.version' => $di['mod_service']('system')->getVersion(),
/**
* Set console application list
* @param array
*/
'console.classes' => function ($di) {
try {
$modules = $di['mod_service']('extension')->getCoreAndActiveModules();
} catch (Exception $e) {
$modules = $di['mod']('extension')->getCoreModules();
}
$fullyQualifiedClassName = [];
// Dynamically load the commands from the modules
foreach ($modules as $module) {
$cap = ucfirst($module);
$commands = glob(__DIR__.'/modules/'.$cap.'/Commands/*.php');
foreach ($commands as $command) {
$commandClass = basename($command, '.php');
// Construct the fully qualified class name
$fullyQualifiedClassName[] = "\\Box\\Mod\\$cap\\Commands\\$commandClass";
}
}
return $fullyQualifiedClassName;
},
'console.allow_namespace' => true,
'console.di' => $di
]);
$console = $di['console'];
$console->run();That will give ability to do php console.php cron:runor php console.php --namespace="\Box\Mod\Cron\Commands\Run" cron:runI need to review the Commands and I will give more feedback cron:run both side |
7 tasks
3e4bf32 to
97ba570
Compare
admdly
approved these changes
Jul 3, 2024
Contributor
|
I've updated this to fix any issues with Huge thanks to @evrifaessa 🙂. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This PR starts working on a basic console application made with Symfony's console component.
I've also added three commands to begin with:
Keeping this as a draft while I'm still experimenting with it. Reviews and suggestions appreciated.
It's pretty easy to write commands. Modules now can have a
/Commandssubdirectory. I'll also update the example modules once this is merged.The component also has great helpers for tables, progress bars and asking for user information.