WEBVTT

NOTE Created by CaptionSync from Automatic Sync Technologies www.automaticsync.com

00:00:01.226 --> 00:00:04.216 align:middle
One of my main goals in these tutorials will be

00:00:04.216 --> 00:00:08.636 align:middle
to help you really understand how
Symfony - how your application - works.

00:00:08.676 --> 00:00:12.076 align:middle
To start with that, let's take a
quick look at the directory structure.

00:00:13.006 --> 00:00:16.586 align:middle
There are only three directories
you need to think about.

00:00:17.056 --> 00:00:22.196 align:middle
First, public/ is the document
root: so it will hold all files

00:00:22.196 --> 00:00:24.806 align:middle
that need to be accessible by a browser.

00:00:25.046 --> 00:00:28.966 align:middle
And... there's only one right now: index.php.

00:00:29.176 --> 00:00:35.026 align:middle
This is called the "front controller": a
fancy word that programmers invented to mean

00:00:35.026 --> 00:00:38.776 align:middle
that this is the file that's
executed by your web server.

00:00:38.996 --> 00:00:43.536 align:middle
But, really, other than putting
CSS or image files into public/,

00:00:43.826 --> 00:00:46.226 align:middle
you'll almost never need to think about it.

00:00:46.226 --> 00:00:49.236 align:middle
So... I kinda lied.

00:00:49.736 --> 00:00:55.866 align:middle
There are truly only two directories that
you need to think about: config/ and src/.

00:00:56.366 --> 00:00:57.356 align:middle
config/ holds...

00:00:57.556 --> 00:00:58.756 align:middle
um... puppies?

00:00:59.296 --> 00:01:06.106 align:middle
No, config/ holds config files and src/
is where all your PHP code will go.

00:01:06.536 --> 00:01:07.996 align:middle
It's just that simple.

00:01:09.236 --> 00:01:10.776 align:middle
Where is Symfony?

00:01:11.276 --> 00:01:14.226 align:middle
Our project started with a composer.json file,

00:01:14.626 --> 00:01:19.906 align:middle
which lists all the third-party
libraries that our app requires.

00:01:20.866 --> 00:01:25.906 align:middle
Behind the scenes, that symfony new
command used composer to install these...

00:01:26.356 --> 00:01:30.386 align:middle
which is a fancy way of saying
that Composer downloaded a bunch

00:01:30.386 --> 00:01:32.946 align:middle
of libraries into the vendor/ directory...

00:01:33.436 --> 00:01:36.356 align:middle
including Symfony itself.

00:01:36.426 --> 00:01:39.896 align:middle
We'll talk more about the other files
and directories along the way...

00:01:40.106 --> 00:01:41.936 align:middle
but they're not important yet.

00:01:41.936 --> 00:01:47.516 align:middle
A few minutes ago, we used PHP
itself to start a local web server.

00:01:47.996 --> 00:01:51.656 align:middle
Cool. But hit Ctrl+C to quit that.

00:01:52.326 --> 00:01:57.556 align:middle
Why? Because that handy symfony
binary tool we installed comes

00:01:57.556 --> 00:01:59.666 align:middle
with a more powerful local server.

00:02:00.536 --> 00:02:03.526 align:middle
Run: symfony serve That's it.

00:02:03.776 --> 00:02:08.786 align:middle
The first time you run this, it may
ask you about installing a certificate.

00:02:09.436 --> 00:02:10.226 align:middle
That's optional.

00:02:10.636 --> 00:02:16.716 align:middle
If you do install it - I did - it
will start the web server with https.

00:02:17.496 --> 00:02:21.716 align:middle
Yep, you get https locally with zero config.

00:02:22.536 --> 00:02:25.676 align:middle
Once it's running, move over
to your browser and refresh.

00:02:26.776 --> 00:02:32.706 align:middle
It works! And the little lock icon
proves that we're now using https.

00:02:33.546 --> 00:02:39.096 align:middle
To stop the web server, just hit Control +
C. You can see all of this command's options

00:02:39.096 --> 00:02:45.096 align:middle
by running: symfony serve -- help
Like ways to control the port number.

00:02:45.886 --> 00:02:55.236 align:middle
When I use this command, I usually run: symfony
serve -d The -d means to run as a daemon.

00:02:55.886 --> 00:03:01.916 align:middle
It does the exact same thing except
that now it runs in the background...

00:03:02.066 --> 00:03:04.386 align:middle
which means I can still use this terminal.

00:03:05.326 --> 00:03:11.476 align:middle
Running: symfony server:status Shows
me that the server is running and:

00:03:11.476 --> 00:03:13.706 align:middle
symfony server:stop Will stop it.

00:03:14.396 --> 00:03:20.426 align:middle
Let's start it again: Ok: we're about
to start doing a lot of coding...

00:03:20.766 --> 00:03:23.676 align:middle
so I want to make sure your
editor is ready to go.

00:03:24.346 --> 00:03:28.316 align:middle
And, yea, you can use whatever editor your want.

00:03:28.946 --> 00:03:31.596 align:middle
But I highly recommend PhpStorm!

00:03:32.296 --> 00:03:36.186 align:middle
Seriously, it makes developing
in Symfony a dream!

00:03:36.486 --> 00:03:41.296 align:middle
And no, the nice people at PhpStorm
aren't paying me to say this...

00:03:41.626 --> 00:03:46.946 align:middle
though... they do actually sponsor
several open source PHP devs...

00:03:46.946 --> 00:03:48.586 align:middle
which is kinda better.

00:03:49.606 --> 00:03:53.366 align:middle
To really make PhpStorm awesome,
you need to do two things.

00:03:53.416 --> 00:03:59.826 align:middle
First, open the Preferences, select
"Plugins" and click "Marketplace".

00:04:01.656 --> 00:04:02.986 align:middle
Search for "Symfony".

00:04:04.836 --> 00:04:07.056 align:middle
This plugin is amazing...

00:04:07.676 --> 00:04:10.986 align:middle
proven by the nearly 4 million downloads.

00:04:11.316 --> 00:04:16.306 align:middle
This will give us all kinds of extra
auto-completion &amp; intelligence for Symfony.

00:04:16.496 --> 00:04:19.976 align:middle
If you don't have it already, install it.

00:04:20.266 --> 00:04:25.636 align:middle
You should also install the "PHP
Annotations" and "PHP toolbox" plugins.

00:04:26.566 --> 00:04:28.786 align:middle
If you search for "php toolbox"...

00:04:29.346 --> 00:04:32.906 align:middle
you can see all three of them.

00:04:33.406 --> 00:04:35.416 align:middle
Install them and restart PhpStorm.

00:04:36.966 --> 00:04:41.876 align:middle
Once you've restarted, go back to
Preferences and Search for Symfony.

00:04:43.426 --> 00:04:50.926 align:middle
In addition to installing the plugin, you also
need to enable it on a project-by-project basis.

00:04:52.326 --> 00:04:54.176 align:middle
Check Enable and then apply.

00:04:55.546 --> 00:04:57.396 align:middle
It says you need to restart PhpStorm...

00:04:57.546 --> 00:04:59.116 align:middle
but I don't think that's true.

00:05:00.526 --> 00:05:06.956 align:middle
The second thing you need to do in PhpStorm is
to search for Composer and find the "Languages

00:05:06.956 --> 00:05:09.616 align:middle
and Frameworks", "PHP", "Composer" section.

00:05:10.036 --> 00:05:16.156 align:middle
Make sure the "Synchronize IDE settings
with composer.json" box is checked...

00:05:16.436 --> 00:05:19.906 align:middle
which automatically configures
several useful things.

00:05:20.996 --> 00:05:22.246 align:middle
Hit "Ok" and...

00:05:22.446 --> 00:05:24.166 align:middle
we are ready!

00:05:24.846 --> 00:05:29.436 align:middle
Let's create our very first page and
see what Symfony is all about, next.

