1. Go to this page and download the library: Download laravelplus/commander library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Generate commander URL
$url = commander_url(); // http://127.0.0.1:8000/admin/commander
$url = commander_url('list'); // http://127.0.0.1:8000/admin/commander/list
// Generate commander routes
$route = commander_route('index'); // commander.index
$route = commander_route('run', ['command' => 'test']); // commander.run
// Check if commander is enabled
if (commander_enabled()) {
// Commander functionality is available
}
use LaravelPlus\Commander\Traits\TracksCommandExecution;
class YourController extends Controller
{
use TracksCommandExecution;
public function runCommand(Request $request)
{
$commandName = 'check:password-expiry';
$arguments = ['--batch-size=10'];
$options = ['--delay=2'];
// Start tracking
$this->startTracking($commandName, $arguments, $options);
try {
// Execute your command
$result = $this->executeCommand($commandName, $arguments, $options);
// Complete tracking with success
$this->completeTracking(true, 0, $result['output']);
return response()->json($result);
} catch (Exception $e) {
// Complete tracking with failure
$this->completeTracking(false, 1, $e->getMessage());
throw $e;
}
}
}
use LaravelPlus\Commander\Models\CommandExecution;
// Get last execution time for a command
$lastExecution = CommandExecution::getLastExecutionTime('check:password-expiry');
// Get execution statistics
$stats = CommandExecution::getCommandStats('check:password-expiry', 30);
// Get recent executions
$recentExecutions = CommandExecution::recent(7)->get();
// Get failed executions
$failedExecutions = CommandExecution::failed()->get();
bash
# Run all tests
php vendor/bin/phpunit
# Run specific test suites
php vendor/bin/phpunit --testsuite=Unit
php vendor/bin/phpunit --testsuite=Feature
# Run with coverage report
php vendor/bin/phpunit --coverage-html coverage/