Installation:
composer require coresphere/console-bundle
Ensure your php version in composer.json is 5.5+ (not overridden by config.platform.php).
Register Bundle:
Add to AppKernel.php under dev/test environments:
$bundles[] = new CoreSphere\ConsoleBundle\CoreSphereConsoleBundle();
Add Route:
Include in routing_dev.yml:
_console:
resource: "@CoreSphereConsoleBundle/Resources/config/routing.yml"
prefix: /console
Access Console:
Visit /console in your browser (dev environment only). Authenticate via Symfony’s security layer (if configured).
/console.cache:clear in the input field.Command Execution:
doctrine: → Bundle suggests doctrine:schema:update, doctrine:migrations:....localStorage (per-browser).cache:clear --no-warmup).Integration with Symfony Security:
CoreSphere\ConsoleBundle\Security\ConsoleAuthenticator to enforce role-based access (e.g., ROLE_ADMIN).# security.yml
access_control:
- { path: ^/console, roles: ROLE_ADMIN }
Custom Commands:
app/Command/MyCommand.php) and tag it with console.command./console UI without extra config.Output Handling:
Table component in commands—outputs as HTML tables.Command Groups:
Organize commands under tabs (e.g., "Doctrine," "Cache") by prefixing names (e.g., doctrine:...).
Tip: Use Command classes with @Route annotations for custom grouping.
API Access: Disable the UI and expose commands via HTTP by:
GET/POST params.Symfony\Component\Console\Application to execute commands programmatically.
Example:$application = new Application();
$application->find('cache:clear')->run(new ArgumentInput([]), new ConsoleOutput());
Logging: Redirect console output to Symfony’s logger:
$output = new StreamOutput(fopen('php://temp', 'w+'));
$logger = new ConsoleLogger($output);
$application->setLogger($logger);
Environment Restriction:
dev/test environments. Forgetting to register it in AppKernel causes 404s.registerBundles() and routing_dev.yml.Security Risks:
# security.yml
providers:
console:
entity: { class: AppBundle\Entity\User }
firewalls:
console:
pattern: ^/console
form_login: ~
ROLE_SUPER_ADMIN for sensitive commands.Output Formatting:
<span> tags in output for critical cases.Command History:
Performance:
doctrine:migrations:migrate) may time out in the browser.404 Errors:
AppKernel.routing_dev.yml.dev/test.Blank Page:
debug:router for route conflicts.twig bundle is loaded (UI uses Twig templates).Command Not Found:
console.command in its service definition:
services:
app.my_command:
class: AppBundle\Command\MyCommand
tags:
- { name: console.command }
Output Issues:
Custom UI:
app/Resources/CoreSphereConsoleBundle/views/ (e.g., default/index.html.twig).Command Filtering:
CoreSphere\ConsoleBundle\Command\ConsoleCommand to hide/show commands dynamically:
public function isEnabled()
{
return $this->getApplication()->getKernel()->getEnvironment() === 'dev';
}
Output Formatting:
CoreSphere\ConsoleBundle\Output\BrowserOutput to modify rendering:
class CustomBrowserOutput extends BrowserOutput
{
protected function getStyle($code)
{
// Customize color mappings
return parent::getStyle($code);
}
}
console.output tag.API Endpoint:
// src/Controller/ConsoleController.php
public function executeCommand(Request $request)
{
$command = $this->get('console')->find($request->query->get('command'));
$command->run(new ArgumentInput([]), new StreamOutput(fopen('php://temp', 'w+')));
return new Response("Done");
}
How can I help you explore Laravel packages today?