Reputation: 9417
I need to set some cron
jobs on a Laravel website. It seems that first I have to run the following command in the shell to begin with it:
php artisan command:make CustomCommand
However since I don't have shell access, my only other option is to use Artisan::call
and access is it over HTTP. The syntax is something like this:
\Artisan::call( 'command:make',
array(
'arg-name' => 'CustomCommand',
'--option' => ''
)
);
The problem that I'm facing is that I can't seem to find the arg-name
value for the command:make
command.
I really appreciate if someone mention the Argument Name for the make
command or suggest an alternative solution that doesn't need shell access.
Upvotes: 0
Views: 365
Reputation: 5755
You can add this manually by creating a class that represents your command. The cli command generates next file :
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class Test extends Command {
/**
* The console command name.
*
* @var string
*/
protected $name = 'command:name';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
//
}
/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return array(
array('example', InputArgument::REQUIRED, 'An example argument.'),
);
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return array(
array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
);
}
}
put it in your commands
directory (for L4 it's app/commands
). Next simply add to your app/start/artisan.php
file the binding for your custom command :
Artisan::add(new Test);
and that's it. This is the ideal solution when you don't need to touch your server's crontab. In case you have access to it from CP it would be the simplest solution. In case you don't have such ability, there would be now way to set the crontab to run your custom command. Hope this helps.
Upvotes: 2