digitalstate/platform-console-bundle
Installation Add the bundle via Composer:
composer require digitalstate/platform-console-bundle
Register the bundle in config/app.php under providers:
DigitalState\PlatformConsoleBundle\PlatformConsoleBundle::class,
First Use Case: Logging Errors Inject the logger service into a controller or command:
use DigitalState\PlatformConsoleBundle\Logger\ConsoleLogger;
public function __construct(private ConsoleLogger $logger) {}
public function someAction() {
try {
// Risky operation
} catch (\Exception $e) {
$this->logger->error('Operation failed', ['exception' => $e]);
}
}
Where to Look First
src/Logger/ConsoleLogger.php for available methods (error, warning, info).src/Command/ for pre-built console utilities (if any exist in future updates).config/platform_console.php (if auto-generated) for customization.Structured Logging Use contextual logging for debugging:
$this->logger->info('User action', [
'user_id' => $user->id,
'action' => 'profile_update',
'metadata' => $payload
]);
Exception Handling Centralize error logging in a middleware or service:
public function handle(Exception $e, $next) {
$this->logger->error('Unhandled exception', ['exception' => $e]);
return $next($request);
}
Todo Integration (Future-Proofing)
If the Todo feature is added later, expect a service like:
$this->todo->create('Refactor payment logic', 'high');
$this->todo->list(); // Hypothetical method
Symfony Console Commands Extend the bundle’s commands (if available) for custom CLI tools:
namespace App\Command;
use DigitalState\PlatformConsoleBundle\Command\BaseCommand;
class CustomCommand extends BaseCommand {
protected function configure() {
$this->setName('app:custom-task');
}
protected function execute(InputInterface $input, OutputInterface $output) {
$this->logger->info('Custom task started');
// Logic here
}
}
Monolog Bridge
If the bundle uses Monolog under the hood, configure it via config/logging.php for advanced formatting.
No Auto-Configuration
Unlike popular bundles (e.g., Laravel’s laravel-debugbar), this bundle lacks auto-discovery. Manually register it in config/app.php.
Limited Documentation
The README is minimal. Assume undocumented features may break or lack consistency. Check the source (src/Logger/ConsoleLogger.php) for exact method signatures.
Todo Feature Unreleased
The Todo section in the README is placeholder text. Avoid relying on it until implemented.
Logger Output
Logs may not appear in storage/logs/laravel.log by default. Verify the bundle’s logger is configured to use Symfony’s logger:
// In PlatformConsoleBundle's service definition
$definition->setArgument('$logger', service('logger'));
Command Testing If extending commands, test with:
php artisan app:custom-task --verbose
Custom Log Channels
Override the logger’s channel in config/logging.php:
'channels' => [
'console' => [
'driver' => 'single',
'path' => storage_path('logs/console.log'),
'level' => 'debug',
],
],
Hook into Log Events
Use Symfony’s monolog.logger event dispatcher to modify logs:
$dispatcher->addListener(Monolog\Logger::INFO, function($record) {
// Transform or filter logs
});
Contributing
Fork the repo and extend the ConsoleLogger class. Submit PRs to add features like:
How can I help you explore Laravel packages today?