gstreamer0.10-ffmpeg
gstreamer0.10-plugins-good
packages.
Let's get to know our new project because my ultimate goal is for you to really understand how things work. As I mentioned, there isn't a lot here yet... about 15 files. And there are really only three directories that we ever need to think or worry about.
The first is public/
... and this is simple: it's the document root. In other words, if you need a file to be publicly accessible - like an image file or a CSS file - it needs to live inside public/
.
Right now, this holds exactly one file: index.php
, which is called the "front controller".
use App\Kernel; | |
require_once dirname(__DIR__).'/vendor/autoload_runtime.php'; | |
return function (array $context) { | |
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); | |
}; |
Ooo. That's a fancy word that means that - no matter what URL the user goes to - this is the script that's always executed first. Its job is to boot up Symfony and run our app. And now that we've looked at it, we'll probably never need to think about or open it ever again.
And, really, other than putting CSS or image files into public/
, this is not a directory you will deal with on a day-to-day basis. Which means... I kinda lied! There are really only two directories that we need to think about: config/
and src/
.
The config/
directory holds... kittens! Oh, I wish. Nah, it holds config files. And src/
holds 100% of your PHP classes. We will spend 95% of our time inside the src/
directory.
Okay... so where is "Symfony"? Our project started with a composer.json
file. This lists all of the third party libraries that our app needs. The "symfony new" command that we ran secretly used "Composer" - that's PHP's package manager - to install these libraries... which is really just a way of saying that Composer downloaded these libraries into the vendor/
directory.
Go Deeper!
If you're not familiar with Composer package manager - check out our separate course called Wonderful World of Composer.
Symfony itself is actually a collection of a bunch of small libraries that each solve a specific problem. In the vendor/symfony/
directory, it looks like we already have about 25 of these. Technically our app only requires these six packages, but some of those packages require other packages... and Composer is smart enough to download everything we need.
Anyways, "Symfony", or really, a set of Symfony libraries, lives in the vendor/
directory and our new app leverages that code to do its job. We're going to talk more about Composer and installing third party packages later. But for the most part, vendor/
is yet another directory that... we don't need to worry about!
So what's left? Well, bin/
holds exactly one file... and will always hold just this one file. We'll talk about what bin/console
does a bit later. And the var/
directory holds cache and log files. Those files are important... but we will never need to look at or think about that stuff.
Yup, we're going to live pretty much entirely inside of the config/
and src/
directories.
Ok, one last piece of homework before we start coding. Feel free to use whatever code editor you want: PhpStorm, VS Code, code carrier pigeon, whatever. But I highly recommend PhpStorm. It makes developing with Symfony a dream... and they're not even paying me to say that! Though, if they do want to start paying me, I accept payment in stroopwafels.
Part of what makes PhpStorm so great is a plugin that's designed specifically for Symfony. I'll go to my PhpStorm preferences and, inside, find Plugins, Marketplace then search for Symfony. Here it is. This plugin is amazing.... which you can see because it's been downloaded 5.4 million times! It adds tons of crazy auto-completion features that are specific to Symfony.
If you don't have it already, get it installed. Once it is installed, go back to Settings and search up here for "Symfony" to find a new Symfony area. The one trick about this plugin is that you need to enable it for each project. So click that check box. Also, it's not too important, but change the web directory to public/
.
Hit Ok and... we are ready! Let's bring our app to life by creating our very first page next.
hi
thank's for the course, now is possible obtains one licency free of PHPStorn?
Hey Andri-C,
Unfortunately we do not provide any free licenses for PhpStorm because we do not have any deals with JetBrains company, we just love PhpStorm and use it internally, so that's not something like a paid promotion. But PhpStorm has the "Early Access Program" that you could learn about here: https://www.jetbrains.com/phpstorm/nextversion/
I hope that helps!
Cheers!
// composer.json
{
"require": {
"php": ">=8.0.2",
"ext-ctype": "*",
"ext-iconv": "*",
"symfony/asset": "6.0.*", // v6.0.3
"symfony/console": "6.0.*", // v6.0.3
"symfony/dotenv": "6.0.*", // v6.0.3
"symfony/flex": "^2", // v2.1.5
"symfony/framework-bundle": "6.0.*", // v6.0.4
"symfony/monolog-bundle": "^3.0", // v3.7.1
"symfony/runtime": "6.0.*", // v6.0.3
"symfony/twig-bundle": "6.0.*", // v6.0.3
"symfony/ux-turbo": "^2.0", // v2.0.1
"symfony/webpack-encore-bundle": "^1.13", // v1.13.2
"symfony/yaml": "6.0.*", // v6.0.3
"twig/extra-bundle": "^2.12|^3.0", // v3.3.8
"twig/twig": "^2.12|^3.0" // v3.3.8
},
"require-dev": {
"symfony/debug-bundle": "6.0.*", // v6.0.3
"symfony/stopwatch": "6.0.*", // v6.0.3
"symfony/web-profiler-bundle": "6.0.*" // v6.0.3
}
}
l am new to symfony and honesty these videos are great