WEBVTT

NOTE Created by CaptionSync from Automatic Sync Technologies www.automaticsync.com

00:00:01.146 --> 00:00:06.496 align:middle
Let's get to know our new project
because my ultimate goal is for you

00:00:06.496 --> 00:00:09.076 align:middle
to really understand how things work.

00:00:09.786 --> 00:00:13.136 align:middle
As I mentioned, there isn't a lot here yet...

00:00:13.216 --> 00:00:14.906 align:middle
about 15 files.

00:00:15.116 --> 00:00:20.756 align:middle
And there are really only three directories
that we ever need to think or worry about.

00:00:20.756 --> 00:00:23.396 align:middle
The first is public/...

00:00:23.546 --> 00:00:27.186 align:middle
and this is simple: it's the document root.

00:00:27.826 --> 00:00:33.146 align:middle
In other words, if you need a file to be
publicly accessible - like an image file

00:00:33.146 --> 00:00:37.016 align:middle
or a CSS file - it needs to live inside public/.

00:00:37.936 --> 00:00:42.026 align:middle
Right now, this holds exactly
one file: index.php,

00:00:42.576 --> 00:00:45.016 align:middle
which is called the "front controller".

00:00:45.186 --> 00:00:51.726 align:middle
Ooo. That's a fancy word that means that
- no matter what URL the user goes to -

00:00:52.106 --> 00:00:55.536 align:middle
this is the script that's always executed first.

00:00:56.216 --> 00:00:59.736 align:middle
Its job is to boot up Symfony and run our app.

00:01:00.216 --> 00:01:06.536 align:middle
And now that we've looked at it, we'll probably
never need to think about or open it ever again.

00:01:07.096 --> 00:01:11.516 align:middle
And, really, other than putting
CSS or image files into public/,

00:01:11.746 --> 00:01:16.326 align:middle
this is not a directory you will
deal with on a day-to-day basis.

00:01:16.516 --> 00:01:17.216 align:middle
Which means...

00:01:17.416 --> 00:01:18.956 align:middle
I kinda lied!

00:01:19.476 --> 00:01:25.156 align:middle
There are really only two directories that
we need to think about: config/ and src/.

00:01:25.236 --> 00:01:27.926 align:middle
The config/ directory holds...

00:01:28.156 --> 00:01:30.296 align:middle
kittens! Oh, I wish.

00:01:30.706 --> 00:01:32.696 align:middle
Nah, it holds config files.

00:01:32.926 --> 00:01:37.706 align:middle
And src/ holds 100% of your PHP classes.

00:01:38.136 --> 00:01:42.336 align:middle
We will spend 95% of our time
inside the src/ directory.

00:01:43.206 --> 00:01:45.876 align:middle
Okay... so where is "Symfony"?

00:01:45.876 --> 00:01:49.806 align:middle
Our project started with a composer.json file.

00:01:50.406 --> 00:01:54.956 align:middle
This lists all of the third party
libraries that our app needs.

00:01:55.546 --> 00:02:00.056 align:middle
The "symfony new" command that
we ran secretly used "composer" -

00:02:00.366 --> 00:02:04.426 align:middle
that's PHP's package manager -
to install these libraries...

00:02:05.106 --> 00:02:07.606 align:middle
which is really just a way of saying

00:02:07.606 --> 00:02:12.256 align:middle
that Composer downloaded these
libraries into the vendor/ directory.

00:02:12.366 --> 00:02:18.416 align:middle
Symfony itself is actually a
collection of a bunch of small libraries

00:02:18.576 --> 00:02:20.636 align:middle
that each solve a specific problem.

00:02:21.746 --> 00:02:27.766 align:middle
In the vendor/symfony/ directory, it looks
like we already have about 25 of these.

00:02:28.376 --> 00:02:32.536 align:middle
Technically our app only
requires these six packages,

00:02:32.706 --> 00:02:36.286 align:middle
but some of those packages
require other packages...

00:02:36.456 --> 00:02:40.066 align:middle
and Composer is smart enough
to download everything we need.

00:02:41.156 --> 00:02:48.326 align:middle
Anyways, "Symfony", or really, a set of Symfony
libraries, lives in the vendor/ directory

00:02:48.576 --> 00:02:52.556 align:middle
and our new app leverages
that code to do its job.

00:02:52.556 --> 00:02:58.016 align:middle
We're going to talk more about Composer
and installing third party packages later.

00:02:58.546 --> 00:03:03.026 align:middle
But for the most part, vendor/
is yet another directory that...

00:03:03.366 --> 00:03:05.266 align:middle
we don't need to worry about!

00:03:06.016 --> 00:03:07.566 align:middle
So what's left?

00:03:08.216 --> 00:03:11.156 align:middle
Well, bin/ holds exactly one file...

00:03:11.646 --> 00:03:14.156 align:middle
and will always hold just this one file.

00:03:14.946 --> 00:03:17.716 align:middle
We'll talk about what bin/console
does a bit later.

00:03:18.186 --> 00:03:21.746 align:middle
And the var/ directory holds
cache and log files.

00:03:22.306 --> 00:03:24.096 align:middle
Those files are important...

00:03:24.286 --> 00:03:28.876 align:middle
but we will never need to look
at or think about that stuff.

00:03:28.916 --> 00:03:35.556 align:middle
Yup, we're going to live pretty much entirely
inside of the config/ and src/ directories.

00:03:36.536 --> 00:03:39.946 align:middle
Ok, one last piece of homework
before we start coding.

00:03:40.066 --> 00:03:45.076 align:middle
Feel free to use whatever code
editor you want: PhpStorm,

00:03:45.226 --> 00:03:48.786 align:middle
VS Code, code carrier pigeon, whatever.

00:03:49.046 --> 00:03:51.586 align:middle
But I highly recommend PhpStorm.

00:03:52.226 --> 00:03:54.726 align:middle
It makes developing with Symfony a dream...

00:03:54.986 --> 00:03:57.646 align:middle
and they're not even paying me to say that!

00:03:57.816 --> 00:04:02.436 align:middle
Though, if they do want to start paying
me, I accept payment in stroopwafels.

00:04:03.206 --> 00:04:09.006 align:middle
Part of what makes PhpStorm so great is a
plugin that's designed specifically for Symfony.

00:04:09.886 --> 00:04:15.556 align:middle
I'll go to my PhpStorm preferences
and, inside, find Plugins,

00:04:16.286 --> 00:04:18.886 align:middle
Marketplace then search for Symfony.

00:04:18.886 --> 00:04:22.066 align:middle
Here it is.

00:04:22.696 --> 00:04:24.676 align:middle
This plugin is amazing....

00:04:24.876 --> 00:04:30.416 align:middle
which you can see because it's
been downloaded 5.4 million times!

00:04:30.786 --> 00:04:35.656 align:middle
It adds tons of crazy auto-completion
features that are specific to Symfony.

00:04:35.656 --> 00:04:39.096 align:middle
If you don't have it already, get it installed.

00:04:39.836 --> 00:04:44.406 align:middle
Once it is installed, go back
to Settings and search up here

00:04:44.406 --> 00:04:47.426 align:middle
for "Symfony" to find a new Symfony area.

00:04:48.576 --> 00:04:53.386 align:middle
The one trick about this plugin is that
you need to enable it for each project.

00:04:54.076 --> 00:04:55.916 align:middle
So click that check box.

00:04:56.786 --> 00:05:01.276 align:middle
Also, it's not too important, but
change the web directory to public/.

00:05:03.736 --> 00:05:05.176 align:middle
Hit Ok and...

00:05:05.426 --> 00:05:07.036 align:middle
we are ready!

00:05:07.606 --> 00:05:12.746 align:middle
Let's bring our app to life by
creating our very first page next.

