REDROOM
PHP 8.3.31
Path:
Logout
Edit File
Size: 3.85 KB
Close
/home/getspomw/royalsquad.us/vendor/laravel/framework/src/Illuminate/Database/Console/MonitorCommand.php
Text
Base64
<?php namespace Illuminate\Database\Console; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\ConnectionResolverInterface; use Illuminate\Database\Events\DatabaseBusy; use Illuminate\Support\Collection; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'db:monitor')] class MonitorCommand extends DatabaseInspectionCommand { /** * The name and signature of the console command. * * @var string */ protected $signature = 'db:monitor {--databases= : The database connections to monitor} {--max= : The maximum number of connections that can be open before an event is dispatched}'; /** * The console command description. * * @var string */ protected $description = 'Monitor the number of connections on the specified database'; /** * The connection resolver instance. * * @var \Illuminate\Database\ConnectionResolverInterface */ protected $connection; /** * The events dispatcher instance. * * @var \Illuminate\Contracts\Events\Dispatcher */ protected $events; /** * Create a new command instance. * * @param \Illuminate\Database\ConnectionResolverInterface $connection * @param \Illuminate\Contracts\Events\Dispatcher $events */ public function __construct(ConnectionResolverInterface $connection, Dispatcher $events) { parent::__construct(); $this->connection = $connection; $this->events = $events; } /** * Execute the console command. * * @return void */ public function handle() { $databases = $this->parseDatabases($this->option('databases')); $this->displayConnections($databases); if ($this->option('max')) { $this->dispatchEvents($databases); } } /** * Parse the database into an array of the connections. * * @param string $databases * @return \Illuminate\Support\Collection */ protected function parseDatabases($databases) { return (new Collection(explode(',', $databases)))->map(function ($database) { if (! $database) { $database = $this->laravel['config']['database.default']; } $maxConnections = $this->option('max'); $connections = $this->connection->connection($database)->threadCount(); return [ 'database' => $database, 'connections' => $connections, 'status' => $maxConnections && $connections >= $maxConnections ? '<fg=yellow;options=bold>ALERT</>' : '<fg=green;options=bold>OK</>', ]; }); } /** * Display the databases and their connection counts in the console. * * @param \Illuminate\Support\Collection $databases * @return void */ protected function displayConnections($databases) { $this->newLine(); $this->components->twoColumnDetail('<fg=gray>Database name</>', '<fg=gray>Connections</>'); $databases->each(function ($database) { $status = '['.$database['connections'].'] '.$database['status']; $this->components->twoColumnDetail($database['database'], $status); }); $this->newLine(); } /** * Dispatch the database monitoring events. * * @param \Illuminate\Support\Collection $databases * @return void */ protected function dispatchEvents($databases) { $databases->each(function ($database) { if ($database['status'] === '<fg=green;options=bold>OK</>') { return; } $this->events->dispatch( new DatabaseBusy( $database['database'], $database['connections'] ) ); }); } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 3 × Files: 9
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
Factories
DIR
-
drwxrwxrwx
2025-09-17 06:53:01
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Migrations
DIR
-
drwxrwxrwx
2025-09-17 06:53:01
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Seeds
DIR
-
drwxrwxrwx
2025-09-17 06:53:01
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DatabaseInspectionCommand.php
1.72 KB
lrw-rw-rw-
2025-09-17 06:53:01
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DbCommand.php
7.26 KB
lrw-rw-rw-
2025-09-17 06:53:01
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DumpCommand.php
2.97 KB
lrw-rw-rw-
2025-09-17 06:53:01
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
MonitorCommand.php
3.85 KB
lrw-rw-rw-
2025-09-17 06:53:01
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
PruneCommand.php
5.94 KB
lrw-rw-rw-
2025-09-17 06:53:01
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ShowCommand.php
8.95 KB
lrw-rw-rw-
2025-09-17 06:53:01
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ShowModelCommand.php
6.79 KB
lrw-rw-rw-
2025-09-17 06:53:01
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
TableCommand.php
8.56 KB
lrw-rw-rw-
2025-09-17 06:53:01
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
WipeCommand.php
2.76 KB
lrw-rw-rw-
2025-09-17 06:53:01
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).