WEBVTT

NOTE Created by CaptionSync from Automatic Sync Technologies www.automaticsync.com

00:00:01.106 --> 00:00:03.566 align:middle
So... let's get these pieces installed!

00:00:04.466 --> 00:00:08.986 align:middle
Back on the install page, the setup details
will vary based on your operating system.

00:00:08.986 --> 00:00:13.996 align:middle
Fortunately, Blackfire has details
for pretty much all situations.

00:00:14.616 --> 00:00:18.096 align:middle
I'm on a Mac and will use
Homebrew to get everything working.

00:00:19.296 --> 00:00:24.756 align:middle
I'll copy the brew tap command, move to
my terminal, open a new tab and paste:

00:00:26.696 --> 00:00:29.706 align:middle
That gives me access to the Blackfire packages.

00:00:30.656 --> 00:00:35.486 align:middle
Now, install the agent - that's the
"daemon" that runs in the background - with:

00:00:35.866 --> 00:00:41.226 align:middle
brew install blackfire-agent Perfect!

00:00:41.816 --> 00:00:44.376 align:middle
It says I need to "register" my agent.

00:00:44.746 --> 00:00:47.756 align:middle
And... the browser instructions confirm that!

00:00:48.456 --> 00:00:56.286 align:middle
I'll copy that command, clear the screen
and paste: This is going to ask us

00:00:56.286 --> 00:00:59.656 align:middle
for our "Server Id" and "Server Token".

00:01:00.396 --> 00:01:00.806 align:middle
These are...

00:01:00.806 --> 00:01:05.456 align:middle
basically an internal "username and
password" that the agent will use

00:01:05.456 --> 00:01:11.076 align:middle
to tell the Blackfire servers which
account the profiles should be attached to.

00:01:11.916 --> 00:01:23.796 align:middle
Copy the Server Id, paste, copy
the Server Token, paste and...

00:01:24.036 --> 00:01:24.566 align:middle
we're good!

00:01:24.566 --> 00:01:29.916 align:middle
Finally, remember how the "agent" is
a service that runs in the background?

00:01:30.566 --> 00:01:34.066 align:middle
We just installed the agent,
but it's not running yet.

00:01:34.816 --> 00:01:39.696 align:middle
Back in the docs, the next two commands
set up the agent as a "service" in Brew,

00:01:39.826 --> 00:01:42.136 align:middle
so that it will always be running.

00:01:42.976 --> 00:01:45.326 align:middle
Copy the first, paste.

00:01:46.706 --> 00:01:50.526 align:middle
Then spin back over again, copy
the launchctl load command...

00:01:50.786 --> 00:01:51.826 align:middle
and paste that.

00:01:53.126 --> 00:01:57.876 align:middle
Cool! If everything worked, the Blackfire
agent is now running in the background.

00:01:58.736 --> 00:02:02.096 align:middle
You wont really ever see it
or care that it's there...

00:02:02.356 --> 00:02:02.996 align:middle
but it is...

00:02:03.356 --> 00:02:04.426 align:middle
waiting for data.

00:02:05.646 --> 00:02:11.316 align:middle
Back on the install docs, the next piece
we need is the PHP extension - the probe.

00:02:12.676 --> 00:02:16.216 align:middle
Skip this CLI tool for now -
we won't need it until later.

00:02:18.456 --> 00:02:21.966 align:middle
To install the PHP extension,
we'll once again use brew.

00:02:22.496 --> 00:02:26.956 align:middle
But... hopefully you're not still using PHP 5.6.

00:02:27.876 --> 00:02:35.696 align:middle
Let me head over to my terminal and see what
version I'm running: php -- version 7.3.6.

00:02:35.936 --> 00:02:36.426 align:middle
Brilliant!

00:02:37.066 --> 00:02:43.566 align:middle
So I'll run: brew install blackfire-php73 Notice

00:02:43.566 --> 00:02:48.946 align:middle
that the extension doesn't need any
authentication info - like a server Id or token.

00:02:49.386 --> 00:02:55.046 align:middle
It's beautifully dumb: its job is to
profile data, send it to the agent,

00:02:55.206 --> 00:02:59.716 align:middle
and let it worry about authentication
with the Blackfire servers.

00:03:00.236 --> 00:03:04.506 align:middle
We do, however, as it says,
need to restart our web server.

00:03:04.506 --> 00:03:09.766 align:middle
For us, that means going to the other
terminal tab, hitting Control + C,

00:03:10.036 --> 00:03:15.776 align:middle
and then running symfony serve Is
the Blackfire extension working?

00:03:16.366 --> 00:03:17.196 align:middle
I don't know!

00:03:17.716 --> 00:03:22.566 align:middle
Because we're using Symfony, an easy way to
check is to hover over the web debug toolbar

00:03:22.696 --> 00:03:25.316 align:middle
and click the "View phpinfo()" link.

00:03:26.426 --> 00:03:26.956 align:middle
Let's see...

00:03:31.506 --> 00:03:34.116 align:middle
yep! The Blackfire PHP extension is here.

00:03:34.966 --> 00:03:38.876 align:middle
At this point, our server is
set up and ready to profile!

00:03:39.216 --> 00:03:45.056 align:middle
Victory! The only thing we need now is a
way to tell the probe when to activate.

00:03:45.466 --> 00:03:47.646 align:middle
That's the job of the browser extension.

00:03:48.386 --> 00:03:51.576 align:middle
Go almost all the way back to
the top of the install page

00:03:51.646 --> 00:03:53.386 align:middle
where they talk about the different pieces.

00:03:54.266 --> 00:03:57.746 align:middle
I'm using Chrome, so I'll click
the Google Chrome extension link.

00:03:59.176 --> 00:04:04.776 align:middle
I don't have it installed yet,
so let's fix that: Add to Chrome.

00:04:10.016 --> 00:04:10.826 align:middle
There it is!

00:04:12.326 --> 00:04:13.546 align:middle
If you refresh the docs...

00:04:15.106 --> 00:04:16.966 align:middle
yep! It sees the extension.

00:04:17.896 --> 00:04:19.916 align:middle
Hey! We're ready to profile!

00:04:20.106 --> 00:04:22.426 align:middle
Ahhhh! Where should we start?

00:04:23.006 --> 00:04:26.946 align:middle
Let's... just click to view
details about any Big Foot sighting.

00:04:28.356 --> 00:04:32.506 align:middle
All of this data comes from
some data fixtures that we used

00:04:32.506 --> 00:04:35.676 align:middle
to pre-populate the database
while setting up the project.

00:04:36.576 --> 00:04:38.806 align:middle
It uses a bunch of random data up here...

00:04:39.126 --> 00:04:42.106 align:middle
and each sighting has a bunch
of random comments.

00:04:42.956 --> 00:04:48.196 align:middle
When we loaded this page a second ago, the
PHP extension - the probe - did nothing.

00:04:48.866 --> 00:04:51.756 align:middle
To activate it, click the browser extension.

00:04:53.456 --> 00:04:54.736 align:middle
Moment of truth!

00:04:55.406 --> 00:05:01.226 align:middle
When we click profile, the plugin will send
a request to this page with a special header

00:05:01.326 --> 00:05:04.146 align:middle
that tells the probe to activate
and start profiling.

00:05:04.996 --> 00:05:05.946 align:middle
Click "Profile"!

00:05:06.716 --> 00:05:07.506 align:middle
There it goes!

00:05:08.666 --> 00:05:15.356 align:middle
It goes from 0 to 100% as it actually
makes 10 requests and averages their data.

00:05:16.566 --> 00:05:19.926 align:middle
We can also give this "profile" a
name to keep our account organized:

00:05:20.636 --> 00:05:24.656 align:middle
I'll say [Recording] Show
page initial and hit enter.

00:05:26.156 --> 00:05:28.516 align:middle
If you got to 100%, congrats!

00:05:28.686 --> 00:05:30.476 align:middle
If you got an error...

00:05:30.806 --> 00:05:35.876 align:middle
wah wah. This is the most common
place for something to go wrong...

00:05:36.056 --> 00:05:41.476 align:middle
and the error will almost always
be the same: Probe not found.

00:05:42.266 --> 00:05:46.126 align:middle
This might mean that you forgot
to install the PHP extension,

00:05:46.406 --> 00:05:51.386 align:middle
or that the PHP extension was
installed on a different PHP binary...

00:05:51.786 --> 00:05:54.236 align:middle
or that the agent isn't running...

00:05:54.566 --> 00:05:59.176 align:middle
or that the agent is running but you
misconfigured the server id and token.

00:05:59.936 --> 00:06:01.756 align:middle
They have great docs to help with this.

00:06:02.076 --> 00:06:03.486 align:middle
But we had success!

00:06:04.126 --> 00:06:08.666 align:middle
Click the "View Call Graph" button
to go to a URL on their site.

00:06:10.156 --> 00:06:13.066 align:middle
Hello beautiful Blackfire profile.

00:06:13.516 --> 00:06:18.816 align:middle
Wow. Next, let's start diving
into this mountain of information

00:06:19.046 --> 00:06:22.476 align:middle
and see how we can use it
to find hidden sasquatch...

00:06:22.696 --> 00:06:25.116 align:middle
I mean, hidden performance bugs.

