console apps: php artisan forthe:win

115
2 0 1 6 2 0 1 6

Upload: joe-ferguson

Post on 22-Jan-2017

138 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Console Apps: php artisan forthe:win

20162016

Page 2: Console Apps: php artisan forthe:win

Console Apps: php artisan forthe:win

Joe Ferguson

Page 3: Console Apps: php artisan forthe:win

Who Am I?Joe Ferguson

PHP Developer

Engineer @ Aol.

Twitter: @JoePFerguson

Organizer of @MemphisPHP

OSMI Board Member

@NomadPHP Lightning Talks

Passionate about Community

Page 4: Console Apps: php artisan forthe:win

Console Apps?!

Page 5: Console Apps: php artisan forthe:win

Shouldn’t we be doing this in __________ ?

Page 6: Console Apps: php artisan forthe:win

Symfony Console

http://symfony.com/doc/current/components/console.html

Page 7: Console Apps: php artisan forthe:win

Symfony Console

Page 8: Console Apps: php artisan forthe:win

Artisan Console

Page 9: Console Apps: php artisan forthe:win

Laravel Artisan

https://laravel.com/docs/5.3/artisan

Page 10: Console Apps: php artisan forthe:win

Artisan Commands

Page 11: Console Apps: php artisan forthe:win

Create a new Command

Page 12: Console Apps: php artisan forthe:win

Create a new Command

Page 13: Console Apps: php artisan forthe:win

app/Console/Kernel.php

Page 14: Console Apps: php artisan forthe:win

BasicCommand.php

Page 15: Console Apps: php artisan forthe:win

Signature

Page 16: Console Apps: php artisan forthe:win

Description

Page 17: Console Apps: php artisan forthe:win

Constructor

Page 18: Console Apps: php artisan forthe:win

Handle The Command

Page 19: Console Apps: php artisan forthe:win

Running our Command

Page 20: Console Apps: php artisan forthe:win

Output Some Text

Page 21: Console Apps: php artisan forthe:win

Output Some Text

Page 22: Console Apps: php artisan forthe:win

Output Warning Text

Page 23: Console Apps: php artisan forthe:win

Output Warning Text

Page 24: Console Apps: php artisan forthe:win

Output Error Text

Page 25: Console Apps: php artisan forthe:win

Output Error Text

Page 26: Console Apps: php artisan forthe:win

How do we test the Command?

Page 27: Console Apps: php artisan forthe:win

BasicCommandTest

Page 28: Console Apps: php artisan forthe:win

BasicCommandTest

Page 29: Console Apps: php artisan forthe:win

Adding Checks

Page 30: Console Apps: php artisan forthe:win

BasicCommandTest

Page 31: Console Apps: php artisan forthe:win

Retrieving Input

Page 32: Console Apps: php artisan forthe:win

Arguments

Page 33: Console Apps: php artisan forthe:win

Arguments

Page 34: Console Apps: php artisan forthe:win

Arguments

Page 35: Console Apps: php artisan forthe:win

Arguments

Page 36: Console Apps: php artisan forthe:win

Multiple Arguments

Page 37: Console Apps: php artisan forthe:win

Multiple Arguments

Page 38: Console Apps: php artisan forthe:win

Options

Page 39: Console Apps: php artisan forthe:win

Options

Page 40: Console Apps: php artisan forthe:win

Options

Page 41: Console Apps: php artisan forthe:win

Options

Page 42: Console Apps: php artisan forthe:win

Options

Page 43: Console Apps: php artisan forthe:win

Prompt User For Input

Page 44: Console Apps: php artisan forthe:win

Prompt User For Input

Page 45: Console Apps: php artisan forthe:win

Prompt User For Input

Page 46: Console Apps: php artisan forthe:win

Ask for Confirmation

Page 47: Console Apps: php artisan forthe:win

Ask for Confirmation

Page 48: Console Apps: php artisan forthe:win

Prompt User For Input

Page 49: Console Apps: php artisan forthe:win

Database Backup

Page 50: Console Apps: php artisan forthe:win

Create DatabaseBackupCommand

Page 51: Console Apps: php artisan forthe:win

app/Console/Commands

Page 52: Console Apps: php artisan forthe:win

Don’t forget Kernel.php!

Page 53: Console Apps: php artisan forthe:win

app/Console/Commands

Page 54: Console Apps: php artisan forthe:win

Look for our Command

Page 55: Console Apps: php artisan forthe:win

Write our handle()

Page 56: Console Apps: php artisan forthe:win

Write our handle()

Page 57: Console Apps: php artisan forthe:win

But we use RDS!

Page 58: Console Apps: php artisan forthe:win

Command SnapshotRds

Page 59: Console Apps: php artisan forthe:win

Write our __construct()

Page 60: Console Apps: php artisan forthe:win

Write our handle()

Page 61: Console Apps: php artisan forthe:win

Running Our Command

Page 62: Console Apps: php artisan forthe:win

AWS Console

Page 63: Console Apps: php artisan forthe:win

I can do that automatically…

Page 64: Console Apps: php artisan forthe:win

What if you don’t use RDS?

Page 65: Console Apps: php artisan forthe:win

spatie/laravel-backup

Page 66: Console Apps: php artisan forthe:win

AWS S3 File Storage

Page 67: Console Apps: php artisan forthe:win

Configure S3ExampleCommand

Page 68: Console Apps: php artisan forthe:win

List items in a bucket

Page 69: Console Apps: php artisan forthe:win

List items in a bucket

Page 70: Console Apps: php artisan forthe:win

Get an object by Key

Page 71: Console Apps: php artisan forthe:win

Get an object by Key

Page 72: Console Apps: php artisan forthe:win

Deleting old assets

Page 73: Console Apps: php artisan forthe:win

Deleting old assets

Page 74: Console Apps: php artisan forthe:win

Cache Data From APIs

Page 75: Console Apps: php artisan forthe:win

Configure CacheApiDataCommand

Page 76: Console Apps: php artisan forthe:win

dms/meetup-api-client

Page 77: Console Apps: php artisan forthe:win

meetupConnect()

Page 78: Console Apps: php artisan forthe:win

handle()

Page 79: Console Apps: php artisan forthe:win

Command Arguments

Page 80: Console Apps: php artisan forthe:win

Default in $signature

Page 81: Console Apps: php artisan forthe:win

We need a way to persist the API data…

Page 82: Console Apps: php artisan forthe:win

Database to the rescue!

Page 83: Console Apps: php artisan forthe:win

Empty Migration

Page 84: Console Apps: php artisan forthe:win

Event Details

Page 85: Console Apps: php artisan forthe:win

Migration up()

Page 86: Console Apps: php artisan forthe:win

Migration down()

Page 87: Console Apps: php artisan forthe:win

Run Migrations

Page 88: Console Apps: php artisan forthe:win

Create Meetup Model

Page 89: Console Apps: php artisan forthe:win

Process the events

Page 90: Console Apps: php artisan forthe:win

Check the database

Page 91: Console Apps: php artisan forthe:win

Now we can pull events from our database

Page 92: Console Apps: php artisan forthe:win

Elasticsearch

Page 93: Console Apps: php artisan forthe:win

Progress Bar

Page 94: Console Apps: php artisan forthe:win

Progress Bar

Page 95: Console Apps: php artisan forthe:win

Progress Bar

Page 96: Console Apps: php artisan forthe:win

Table Layout

Page 97: Console Apps: php artisan forthe:win

Table Layout

Page 98: Console Apps: php artisan forthe:win

20 Events is a pretty small data set

Page 99: Console Apps: php artisan forthe:win

GetAllMeetups*

*not all meetups

Page 100: Console Apps: php artisan forthe:win

GetAllMeetups Command

Page 101: Console Apps: php artisan forthe:win

A larger meetup group

Page 102: Console Apps: php artisan forthe:win

Update the handle()

Page 103: Console Apps: php artisan forthe:win

Run our command

Page 104: Console Apps: php artisan forthe:win

Check the database

Page 105: Console Apps: php artisan forthe:win

Batch Process Large Data Sets

Page 106: Console Apps: php artisan forthe:win

Configure BatchProcessCommand

Page 107: Console Apps: php artisan forthe:win

handle() BatchProcessCommand

Page 108: Console Apps: php artisan forthe:win

Running meetup:expire

Page 109: Console Apps: php artisan forthe:win

Schedule Our Commands

Page 110: Console Apps: php artisan forthe:win

artisan schedule:run

Page 111: Console Apps: php artisan forthe:win

Scheduling Commands

app/Console/Kernel.php

Page 112: Console Apps: php artisan forthe:win

Scheduling Commands

Page 113: Console Apps: php artisan forthe:win

Real World Twitter Demo

Page 114: Console Apps: php artisan forthe:win

Questions?

Page 115: Console Apps: php artisan forthe:win

Joe FergusonTwitter: @JoePFergusonEmail: [email protected]: joepferguson

Contact Info:

https://github.com/svpernova09/ConsoleAppsForTheWin