$30 off During Our Annual Pro Sale. View Details »

Laravel Zero

Laravel Zero

Hunter Skrasek

May 03, 2018
Tweet

More Decks by Hunter Skrasek

Other Decks in Programming

Transcript

  1. Laravel Zero
    Laravel Zero - Laravel Austin 1

    View Slide

  2. Micro-framework
    for command-line applications
    Provides an elegant starting point for your console
    application
    Laravel Zero - Laravel Austin 2

    View Slide

  3. Installation
    Laravel Zero - Laravel Austin 3

    View Slide

  4. Installation
    — composer global require "laravel-zero/installer"
    Laravel Zero - Laravel Austin 3

    View Slide

  5. Installation
    — composer global require "laravel-zero/installer"
    — composer create-project --prefer-dist laravel-zero/
    laravel-zero movie-cli
    Laravel Zero - Laravel Austin 3

    View Slide

  6. Commands
    By default Laravel Zero comes with a InspiringCommand as
    an example
    php make:command
    Laravel Zero - Laravel Austin 4

    View Slide

  7. Desktop Notifications
    $this->notify("Hello Web Artisan", "Love beautiful..", "icon.png");
    Laravel Zero - Laravel Austin 5

    View Slide

  8. Tasks
    $this->task("Installing Laravel", function () {
    return true;
    });
    $this->task("Doing something else", function () {
    return false;
    });
    Laravel Zero - Laravel Austin 6

    View Slide

  9. 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

    View Slide

  10. Service Providers
    Laravel Zero recommends using Service Providers for
    defining concrete implementations
    Laravel Zero - Laravel Austin 8

    View Slide

  11. Config
    Laravel Zero utilizes the same configuration system as
    Laravel.
    'production' => true,
    Laravel Zero - Laravel Austin 9

    View Slide

  12. Database
    Laravel Zero allows you to install a Laravel's Eloquent
    component
    php app:install database
    Laravel Zero - Laravel Austin 10

    View Slide

  13. Logging
    php app:install log
    Laravel Zero - Laravel Austin 11

    View Slide

  14. 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

    View Slide

  15. 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

    View Slide

  16. Environment Configuration
    Laravel Zero also supports DotEnv based environment
    configuration
    php app:install dotenv
    Laravel Zero - Laravel Austin 14

    View Slide

  17. Collision
    A detailed and intuitive error handler framework for
    console applications
    Laravel Zero - Laravel Austin 15

    View Slide

  18. Tinker
    Laravel Zero is a powerful REPL for Laravel
    Laravel Zero - Laravel Austin 16

    View Slide

  19. 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

    View Slide

  20. DEMO
    Laravel Zero - Laravel Austin 18

    View Slide