Skip to content

Commit

Permalink
Merge branch 'midwest-php'
Browse files Browse the repository at this point in the history
  • Loading branch information
stevegrunwell committed Mar 7, 2019
2 parents 1d6e676 + e2323af commit 146130b
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 58 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ This presentation also has [a companion repository, full of executable examples

## Presentation History

* [WavePHP 2018](https://wavephp.com/) — September 20, 2018 ([join.in](https://joind.in/talk/6908c), [PDF](https://github.com/stevegrunwell/building-for-php-cli/releases/download/wavephp-2018/slides.pdf))
* [Southeast PHP](https://southeastphp.com/) - August 17, 2018 ([PDF](https://github.com/stevegrunwell/building-for-php-cli/releases/download/southeastphp-2018/slides.pdf), [joind.in](https://joind.in/talk/ed2e4))
* [PHPDetroit](https://phpdetroit.io/) - July 28, 2018 ([PDF](https://github.com/stevegrunwell/building-for-php-cli/releases/download/phpdetroit-2018/slides.pdf), [joind.in](https://joind.in/talk/e6d00))
* [php[tek] 2018](https://tek18.phparch.com/speakers/steve-grunwell/) - May 31, 2018 ([PDF](https://github.com/stevegrunwell/building-for-php-cli/releases/download/phptek-2018/slides.pdf), [joind.in](https://joind.in/talk/c6025))
* [Midwest PHP 2019](https://2019.midwestphp.org/) — March 8, 2019 ([Joind.in](https://joind.in/talk/b9a05))
* [WavePHP 2018](https://wavephp.com/) — September 20, 2018 ([Joind.in](https://joind.in/talk/6908c), [PDF](https://github.com/stevegrunwell/building-for-php-cli/releases/download/wavephp-2018/slides.pdf))
* [Southeast PHP](https://southeastphp.com/) - August 17, 2018 ([Joind.in](https://joind.in/talk/ed2e4), [PDF](https://github.com/stevegrunwell/building-for-php-cli/releases/download/southeastphp-2018/slides.pdf))
* [PHPDetroit](https://phpdetroit.io/) - July 28, 2018 ([Joind.in](https://joind.in/talk/e6d00), [PDF](https://github.com/stevegrunwell/building-for-php-cli/releases/download/phpdetroit-2018/slides.pdf))
* [php[tek] 2018](https://tek18.phparch.com/speakers/steve-grunwell/) - May 31, 2018 ([Joind.in](https://joind.in/talk/c6025), [PDF](https://github.com/stevegrunwell/building-for-php-cli/releases/download/phptek-2018/slides.pdf))
* [Music City Code 2017](https://www.musiccitycode.com/) - June 3, 2017
* [CodeMash 2017](http://www.codemash.org/) - January 13, 2017
* [Nomad PHP (EU)](https://nomadphp.com/nomadphp-2016-12-eu/) – December 15, 2016 ([joind.in](https://joind.in/talk/dce28))
* [php[tek] 2016](https://tek16.phparch.com/speakers/#66432) – May 27, 2016 ([joind.in](https://joind.in/talk/ce9a4))
* [Columbus PHP Meetup](http://www.meetup.com/phpphp/events/229434721/) – April 13, 2016 ([joind.in](https://joind.in/talk/e9465))
* [Nomad PHP (EU)](https://nomadphp.com/nomadphp-2016-12-eu/) – December 15, 2016 ([Joind.in](https://joind.in/talk/dce28))
* [php[tek] 2016](https://tek16.phparch.com/speakers/#66432) – May 27, 2016 ([Joind.in](https://joind.in/talk/ce9a4))
* [Columbus PHP Meetup](http://www.meetup.com/phpphp/events/229434721/) – April 13, 2016 ([Joind.in](https://joind.in/talk/e9465))
4 changes: 2 additions & 2 deletions css/source/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// ---------------------------------------------

// Include theme-specific fonts
@import url('https://fonts.googleapis.com/css?family=Montserrat|Open+Sans');
@import url('https://fonts.googleapis.com/css?family=Open+Sans|Paytone+One');

// Override theme settings (see ../../bower_components/reveal.js/css/theme/template/settings.scss)
$backgroundColor: #fff;
Expand All @@ -20,7 +20,7 @@ $headingColor: #333;

$mainFontSize: 38px;
$mainFont: 'Open Sans', sans-serif;
$headingFont: Montserrat, 'Open Sans', sans-serif;
$headingFont: 'Paytone One', 'Open Sans', sans-serif;
$headingTextShadow: none;
$headingLetterSpacing: normal;
$headingTextTransform: uppercase;
Expand Down
6 changes: 3 additions & 3 deletions css/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* By Hakim El Hattab, http://hakim.se
*/
@import url("https://fonts.googleapis.com/css?family=Montserrat|Open+Sans");
@import url("https://fonts.googleapis.com/css?family=Open+Sans|Paytone+One");
section.has-dark-background, section.has-dark-background h1, section.has-dark-background h2, section.has-dark-background h3, section.has-dark-background h4, section.has-dark-background h5, section.has-dark-background h6 {
color: #fff; }

Expand Down Expand Up @@ -41,7 +41,7 @@ body {
.reveal h6 {
margin: 0 0 20px 0;
color: #333;
font-family: Montserrat, "Open Sans", sans-serif;
font-family: "Paytone One", "Open Sans", sans-serif;
font-weight: 400;
line-height: 1.2;
letter-spacing: normal;
Expand Down Expand Up @@ -334,7 +334,7 @@ body {
clear: both;
float: left;
width: 35%;
font-family: Montserrat, "Open Sans", sans-serif;
font-family: "Paytone One", "Open Sans", sans-serif;
text-align: right; }
.slides dl dd {
clear: right;
Expand Down
Binary file removed resources/emily.jpg
Binary file not shown.
5 changes: 0 additions & 5 deletions slides/about-me.md

This file was deleted.

1 change: 0 additions & 1 deletion slides/emily.md

This file was deleted.

24 changes: 13 additions & 11 deletions slides/environment-variables.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
### Environment Variables

```php
$name = getenv('DEMO_NAME');
$apiKey = getenv('API_KEY');

if ($name) {
printf('Hey, I recognize you, %s!' . PHP_EOL, $name);
$name = sprintf('My old friend, %s!', $name);
// It wasn't provided via environment variable.
if (! $apiKey && ! empty($argv[1])) {
$apiKey = $argv[1];
}

} else {
echo "I don't know you, so I'll just call you Fred." . PHP_EOL;
$name = 'Fred';
// Neither environment nor argument.
if (! $apiKey) {
echo 'An API key must be provided!';
exit(1);
}

// Update DEMO_NAME and call the system's echo program.
putenv('DEMO_NAME=' . $name);
passthru('echo $DEMO_NAME');
echo "API Key: $apiKey";
```

Note:

Another neat trick is the ability to access environment variables from within your PHP script.
Another neat trick is the ability to access environment variables from within your PHP script.

Can use both getenv() and putenv().
29 changes: 21 additions & 8 deletions slides/environment-variables2.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
### Environment Variables

`export DEMO_NAME="Steve"`
```html
> Hey, I recognize you, Steve!
> My old friend, Steve!
```sh
$ API_KEY=abc123 php my-script.php

API Key: abc123
```
<!-- .element: class="fragment" -->

```sh
$ php my-script.php xyz789

<br>Otherwise:
```html
> I don't know you, so I'll just call you Fred.
> Fred
API Key: xyz789
```
<!-- .element: class="fragment" -->

```sh
$ API_KEY=abc123 php my-script.php xyz789

API Key: abc123
```
<!-- .element: class="fragment" -->

Note:

Since the script was checking for the environment variable first, that will take precedence when the script is run.
2 changes: 1 addition & 1 deletion slides/escaping-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exec('greet-user ' . $name);
```
<!-- .element: class="fragment" data-fragment-index="1" -->

##### Much Better:
Much Better:
<!-- .element: class="fragment" data-fragment-index="2" -->

```php
Expand Down
9 changes: 8 additions & 1 deletion slides/exit-codes2.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ if (! isset($argv['1'])) {
exit(1);
}

// Do something awesome
echo "Script ran!";
```

```sh
$ php my-script.php foo && echo "Success"
> Script ran!
> Success
```
<!-- .element: class="fragment" -->

```sh
$ php my-script.php && echo "You will never see this"
> Missing required argument!
```
<!-- .element: class="fragment" -->

Expand Down
8 changes: 2 additions & 6 deletions slides/list.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
[
"index.md",
[
"about-me.md",
"emily.md"
],
[
"why-the-cli.md",
"benefits.md",
Expand Down Expand Up @@ -42,10 +38,10 @@
"escaping-shell-commands.md",
"escapeshellcmd.md",
"escaping-arguments.md",
"environment-variables.md",
"environment-variables2.md",
"exit-codes.md",
"exit-codes2.md",
"environment-variables.md",
"environment-variables2.md",
"daemons.md"
],
[
Expand Down
10 changes: 2 additions & 8 deletions slides/php-cli-tools-example2.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@
$ php examples/PHPCliToolsExample.php
```

```html
$ php examples/PHPCliToolsExample.php
How high should I count? [10]: 5
Shall I shout it? [y/N]y
1!
<pre class="hljs lang-html fragment"><code>How high should I count? [10]: 5</code><code class="fragment">Shall I shout it? [y/N]y</code><code class="fragment">1!
2!
3!
4!
5!
```
<!-- .element: class="fragment" -->
5!</code></pre>
1 change: 1 addition & 0 deletions slides/php-sapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ if ('cli' !== php_sapi_name()) {

Note:

* Used to running in something like the fpm-fcgi SAPI for web requests.
* Use the php_sapi_name() function or PHP_SAPI constant to determine the server API being used
7 changes: 4 additions & 3 deletions slides/thank-you.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## Thank You!

Steve Grunwell<br>
[stevegrunwell.com](https://stevegrunwell.com)<br>
[liquidweb.com](https://www.liquidweb.com)
Senior Software Engineer, Liquid Web

[stevegrunwell.com/slides/php-cli](https://stevegrunwell.com/slides/php-cli)<!-- .element: class="slides-link" -->
<p class="slides-link">
[stevegrunwell.com/slides/php-cli](https://stevegrunwell.com/slides/php-cli)<br>[joind.in/talk/b9a05](https://joind.in/talk/b9a05)
</p>
4 changes: 3 additions & 1 deletion slides/wp-cli-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ WP_CLI::add_command( 'example-command', 'Example_WP_CLI_Command' );

Note:

Looking at WP-CLI commands, they're registered using the WP_CLI::add_command() method.
Looking at WP-CLI commands, they're registered using the WP_CLI::add_command() method.

Each command class will contain at least one public method, each of which will become sub-commands (e.g. "wp example-command some-function").
2 changes: 1 addition & 1 deletion templates/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


<!-- For syntax highlighting -->
<link rel="stylesheet" href="bower_components/highlightjs/styles/zenburn.css">
<link rel="stylesheet" href="bower_components/highlightjs/styles/github.css">

<!-- Printing and PDF exports -->
<script>
Expand Down

0 comments on commit 146130b

Please sign in to comment.