पर मैं एक नया वर्ग बनाया src/CollaboratorsBundle/कमान में, यह GenerateFormRemindersCommand.php नामित और यह में निम्नलिखित कोड डालें:Symfony2 कस्टम सांत्वना आदेश प्रकट होता है के रूप में "परिभाषित नहीं" निष्पादन
<?php
namespace Myproject\CollaboratorsBundle\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
class GenerateFormRemindersCommand extends ContainerAwareCommand{
protected function configure() {
$this->setName("generate:formReminders")
->setDescription('Send reminders by email to all collaborators with unanswered forms');
}
protected function execute(InputInterface $input, OutputInterface $output) {
//some code
}
}
निष्पादन पर, मुझे निम्न संदेश मिलता है:
$ php app/console generate:formReminders
[InvalidArgumentException]
Command "generate:formReminders" is not defined.
मैंने अपनी AppKernel.php फ़ाइल में चेक किया है कि मेरा बंडल इसमें पंजीकृत था और यह था।
मैंने अभिभावक जोड़ने का प्रयास किया है: कॉन्फ़िगर करें(); कॉन्फ़िगरेशन विधि पर लेकिन बिना किसी परिणाम के।
मैंने कुछ अन्य कस्टम आदेश बनाए हैं जो सही तरीके से काम करते हैं। मैं इस मामले में गलत नहीं कर रहा हूं। क्या आप ?
अग्रिम धन्यवाद
आपको पता नहीं है कि यह जवाब कितना सही है। शीश। बस मेरे लिए निराशा के आधा घंटे समाप्त हो गया। –
@ जारोड, हाँ, एक घंटे भी बिताया। और मुझे अभी भी समझ में नहीं आ रहा है कि यह आदेश 'कमांड' प्रत्यय क्यों आवश्यक है, भले ही सभी आदेशों के लिए एक विशेष नामस्थान हो। –
यहां सिम्फनी वेबसाइट से एक संदर्भ है जो वास्तव में यह कह रहा है: http://symfony.com/doc/current/cookbook/console/console_command.html#automatically-registering-commands – syss