Laravel Zero provides an elegant starting point for your next Laravel Console Application.
Is an MIT-licensed open source project UNDER DEVELOMENT.
Laravel Zero utilizes Composer to manage its dependencies. So, before using Laravel Zero, make sure you have Composer installed on your machine.
Install Laravel Zero by issuing the Composer create-project
command in your terminal:
composer create-project --prefer-dist nunomaduro/laravel-zero application-name
Laravel Zero provides a main command. That is the default one of your application, placed in app/Console/Commands/Main.php. You should fill in the signature
and description
properties of the class, which will be used when displaying your command on the list
screen. The handle
method will be called when your command is executed. You may place your command logic in this method.
Let's take a look at an example command.
<?php
namespace App\Console\Commands;
use App\DripEmailer;
use Illuminate\Console\Command;
class SendEmails extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'email:send {email}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Send drip e-mails to a email';
/**
* The drip e-mail service.
*
* @var DripEmailer
*/
protected $drip;
/**
* Create a new command instance.
*
* @param DripEmailer|null $drip
* @return void
*/
public function __construct(DripEmailer $drip = null)
{
parent::__construct();
$this->drip = $drip ?: new DripEmailer;
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->drip->send($this->argument('email'));
}
}
You may review the documentation of the Artisan Console component on Laravel Official Website.
- For latest releases and announcements, follow on Twitter: @enunomaduro
Copyright (c) 2017-2017 Nuno Maduro