Laravel 5 के बाद से, यह मेरे लिए ब्याज है - रजिस्टर करने के लिए कैसे और Laravel 5.लैरवेल 5 में पैकेज से कंसोल कमांड को कैसे पंजीकृत करें?
में पैकेज से कंसोल आदेश का उपयोग laracast में के रूप में https://laracasts.com/discuss/channels/tips/developing-your-packages-in-laravel-5 पर चर्चा, मैं एक निर्देशिका संरचना बनाने के लिए, autoload करने के लिए अपने पैकेज जोड़ सकते हैं और एक सेवा बनाने प्रदाता
<?php namespace Goodvin\EternalTree;
use Console\InstallCommand;
use Illuminate\Support\ServiceProvider;
class EternalTreeServiceProvider extends ServiceProvider
{
public function boot()
{
}
public function register()
{
$this->registerCommands();
}
protected function registerCommands()
{
$this->registerInstallCommand();
}
protected function registerInstallCommand()
{
$this->app->singleton('command.eternaltree.install', function($app) {
return new InstallCommand();
});
}
public function provides()
{
return [
'command.eternaltree.install'
];
}
}
मेरे InstallCommand.php स्क्रिप्ट/src/कंसोल
<?php namespace Goodvin\EternalTree\Console;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class InstallCommand extends Command {
protected $name = 'install:eternaltree';
protected $description = 'Command for EternalTree migration & model install.';
public function __construct()
{
parent::__construct();
}
public function fire()
{
$this->info('Command eternaltree:install fire');
}
}
में संग्रहीत मैं app.php & में सेवा प्रदाता रजिस्टर पर अमल डंप-autoload। लेकिन जब मैं
php artisan eternaltree:install
पर अमल करने की कोशिश यह मेरे
[InvalidArgumentException] There are no commands defined in the "eternaltree" namespace.
दिखाने मुझे लगता है कि मेरी आदेश सेवा प्रदाता द्वारा पंजीकृत नहीं है, क्योंकि php कारीगर सूची मेरा आदेश नहीं दिखाती है। क्या कोई मुझे बता सकता है कि लैरवेल 5 में अपने पैकेज में कमांड को पंजीकृत करने का सही तरीका क्या है?
था के रूप में आप का सुझाव दिया: - लागू MyServiceProvider ServiceProvider तो '' 'सार्वजनिक समारोह रजिस्टर() फैली हुई है { // $ this-> आदेश ([ LaravelTypesController :: वर्ग ]); } '' - लैरावेल टाइप्स नियंत्रक $ हस्ताक्षर के साथ कमांड बढ़ाता है, $ विवरण और विधि को संभालता है, लेकिन फिर भी php artisan पर कमांड नहीं दिखता है। ग्रेप –