Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Laravel Zero

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Laravel Zero

Avatar for Hunter Skrasek

Hunter Skrasek

May 03, 2018
Tweet

More Decks by Hunter Skrasek

Other Decks in Programming

Transcript

  1. Micro-framework for command-line applications Provides an elegant starting point for

    your console application Laravel Zero - Laravel Austin 2
  2. Commands By default Laravel Zero comes with a InspiringCommand as

    an example php <your-app-name> make:command <NewCommand> Laravel Zero - Laravel Austin 4
  3. Tasks $this->task("Installing Laravel", function () { return true; }); $this->task("Doing

    something else", function () { return false; }); Laravel Zero - Laravel Austin 6
  4. Interactive Menus $option = $this->menu('Pizza menu', [ 'Freshly baked muffins',

    'Freshly baked croissants', 'Turnovers, crumb cake, cinnamon buns, scones', ])->open(); $this->info("You have chosen the option number #$option"); $this->menu($title, $options) ->setForegroundColour('green') ->setBackgroundColour('black') ->setWidth(200) ->setPadding(10) ->setMargin(5) ->setExitButtonText("Abort") // remove exit button with // ->disableDefaultItems() ->setUnselectedMarker('❅') ->setSelectedMarker('✏') ->setTitleSeparator('*-') ->addLineBreak('<3', 2) ->addStaticItem('AREA 2') ->open(); Laravel Zero - Laravel Austin 7
  5. Service Providers Laravel Zero recommends using Service Providers for defining

    concrete implementations Laravel Zero - Laravel Austin 8
  6. Config Laravel Zero utilizes the same configuration system as Laravel.

    'production' => true, Laravel Zero - Laravel Austin 9
  7. Database Laravel Zero allows you to install a Laravel's Eloquent

    component php <your-app-name> app:install database Laravel Zero - Laravel Austin 10
  8. Filesystem Laravel Zero ships with the Filesystem component by default

    use Illuminate\Support\Facades\Storage; Storage::put("reminders.txt", "Task 1"); Laravel Zero - Laravel Austin 12
  9. Scheduler Laravel Zero ships with the Task Scheduling system of

    Laravel * * * * * php /path-to-your-project/your-app-name schedule:run >> /dev/null 2>&1 public function schedule(Schedule $schedule): void { $schedule->command(static::class)->everyMinute(); } Laravel Zero - Laravel Austin 13
  10. Environment Configuration Laravel Zero also supports DotEnv based environment configuration

    php <your-app-name> app:install dotenv Laravel Zero - Laravel Austin 14
  11. Collision A detailed and intuitive error handler framework for console

    applications Laravel Zero - Laravel Austin 15
  12. Tests use Tests\TestCase; use Illuminate\Support\Facades\Artisan; class InspiringCommandTest extends TestCase {

    /** * A basic test example. */ public function testInspiringCommand(): void { Artisan::call('inspiring'); $this->assertContains('Leonardo da Vinci', Artisan::output()); } } Laravel Zero - Laravel Austin 17