alanvdb / symfony-console-application
Project template for Symfony console application.
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^8.2
- symfony/config: ^7.2
- symfony/console: ^7.2
- symfony/dependency-injection: ^7.2
- symfony/yaml: ^7.2
Requires (Dev)
- phpunit/phpunit: ^11.5
This package is auto-updated.
Last update: 2025-05-22 13:46:32 UTC
README
Project template for Symfony console application. A ready-to-use foundation for building powerful CLI applications with Symfony Console components.
Installation
composer create-project alanvdb/symfony-console-application project-name
Features
- 🚀 Ready-to-use Symfony Console application structure
- âš¡ Dependency Injection container pre-configured
- 📦 Includes common Symfony components:
- Console
- DependencyInjection
- Config
- Yaml
- 📂 Organized project structure
- 🔄 Automatic command discovery
- 🛠Example command included
Getting Started
- Run your application:
cd project-name
./bin/console
- See available commands:
./bin/console list
- Run the example command:
./bin/console app:example
Creating New Commands
- Create a new PHP class in
src/
(e.g.,NewCommand.php
) - Extend
Symfony\Component\Console\Command\Command
- Use the
#[AsCommand]
attribute or implementconfigure()
method
Example command:
<?php namespace App\Command; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand( name: 'app:new', description: 'My new command' )] class NewCommand extends Command { protected function execute(InputInterface $input, OutputInterface $output): int { $output->writeln('Command executed!'); return Command::SUCCESS; } }
The command will be automatically registered in your application.
Configuration
Services
Edit config/services.yaml
to:
- Add new service definitions
- Modify autowiring settings
- Register additional namespaces
Environment Variables
- Copy
.env.template
to.env
- Add your environment-specific variables
Testing
The template includes PHPUnit configuration. To run tests:
composer test
Included Symfony Components
symfony/console
: CLI application foundationsymfony/dependency-injection
: Service containersymfony/config
: Configuration managementsymfony/yaml
: YAML configuration support
Adding More Components
To add additional Symfony components:
composer require symfony/component-name
Recommended additions:
composer require symfony/filesystem composer require symfony/process composer require symfony/finder
Best Practices
- Keep commands thin - move business logic to services
- Use the dependency injection container for service management
- Follow Symfony's command naming conventions (
namespace:action
) - Document your commands with proper descriptions and help texts
License
MIT License. See included LICENSE file.
Contributing
Contributions are welcome! Please open an issue or pull request on GitHub.