Chapters
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Bienvenido. Hola. Hola, mi nombre es Ryan y tengo el absoluto placer de presentarte el hermoso y fascinante y productivo mundo de Symfony 6. En serio, me siento como Willie Wonka invitándote a mi fábrica de chocolate, excepto que, con suerte, con menos lesiones relacionadas con el azúcar. De todos modos, si eres nuevo en Symfony, estoy... ¡sinceramente un poco celoso! Te va a encantar el viaje... y espero que te conviertas en un desarrollador aún mejor por el camino: definitivamente vas a construir cosas geniales.
La salsa secreta de Symfony es que empieza siendo diminuto, lo que hace que sea fácil de aprender. Pero luego, amplía sus características automáticamente a través de un sistema de recetas único. En Symfony 6, esas características incluyen nuevas herramientas de JavaScript y un nuevo sistema de seguridad... sólo por nombrar dos de las muchas cosas nuevas.
Symfony también es rápido como un rayo, con un gran enfoque en la creación de una experiencia alegre para el desarrollador, pero sin sacrificar las mejores prácticas de programación. Sí: consigues amar la codificación y amar tu código. Lo sé... ha sonado cursi, pero es cierto.
Así que ven conmigo y estarás en un mundo de pura elucidación.
Es la primera vez que canto en estos tutoriales... y quizá la última. Empecemos.
Instalar el binario "symfony
Dirígete a https://symfony.com/download. En esta página, encontrarás algunas instrucciones -que variarán en función de tu sistema operativo- sobre cómo descargar algo llamado el binario de Symfony.
Esto... no es realmente Symfony. Es sólo una herramienta de línea de comandos que nos ayudará a iniciar nuevos proyectos Symfony y nos dará algunas buenas herramientas de desarrollo local. Es opcional, pero lo recomiendo encarecidamente
Una vez que hayas instalado esto - yo ya lo he hecho - abre tu aplicación de terminal favorita. Yo estoy usando iTerm para mac, pero no importa. Si lo has configurado todo correctamente, deberías poder ejecutarlo:
symfony
O incluso mejor
symfony list
para ver una lista de todas las "cosas" que puede hacer este binario de symfony. Hay muchas cosas aquí: cosas que ayudan al desarrollo "local"... y también algunos servicios opcionales para el despliegue. Vamos a repasar las cosas que necesitas saber a lo largo del camino.
¡Iniciemos una aplicación Symfony!
Bien, queremos iniciar una nueva y brillante aplicación Symfony. Para ello, ejecuta:
symfony new mixed_vinyl
Donde "mixed_vinyl" es el directorio en el que se descargará la nueva app. Se trata de nuestro proyecto secreto para combinar la mejor parte de los años 90 -no, no el Internet de acceso telefónico, hablo de las cintas de mezcla- con el deleite auditivo de los discos. Más adelante hablaremos de ello.
Entre bastidores, este comando utiliza Composer -el gestor de paquetes de PHP- para crear el nuevo proyecto. Más adelante hablaremos de ello.
El resultado final es que podemos pasar a nuestro nuevo directorio mixed_vinyl
. Abre esta carpeta en tu editor favorito. Yo estoy usando PhpStorm y lo recomiendo encarecidamente.
Conociendo nuestro nuevo Proyecto
¿Qué ha hecho ese comando symfony new
? Ha arrancado un nuevo proyecto Symfony! Ooh. Y ya tenemos un repositorio git. Ejecuta:
git status
Sí: en la rama principal, nada que confirmar. Prueba:
git log
Genial. Después de descargar el nuevo proyecto, el comando confirmó todos los archivos originales automáticamente... lo cual fue muy agradable. Aunque me gustaría que el primer mensaje de confirmación fuera un poco más rockero.
¡Lo que realmente quiero mostrarte es que nuestro nuevo proyecto es súper pequeño! Prueba este comando:
git show --name-only
¡Sí! Todo nuestro proyecto es... unos 17 archivos. Y aprenderemos sobre todos ellos a lo largo del camino. Pero quiero que te sientas cómodo: no hay mucho código aquí.
Vamos a añadir funciones poco a poco. Pero si quieres empezar con un proyecto más grande y con más funciones, puedes hacerlo ejecutando el comando symfony new
con --webapp
.
Tip
Si quieres una nueva aplicación Symfony con todas las funciones, echa un vistazo a https://github.com/dunglas/symfony-docker
Comprobación de los requisitos del sistema
Antes de saltar a la codificación, vamos a asegurarnos de que nuestro sistema está listo. Ejecuta otro comando del binario de symfony:
symfony check:req
¡Parece que está bien! Si a tu instalación de PHP le falta alguna extensión... o hay algún otro problema... como que tu ordenador es en realidad una tetera, esto te lo hará saber.
Iniciar el servidor web de desarrollo
Entonces: tenemos una nueva aplicación Symfony aquí... ¡y nuestro sistema está listo! Todo lo que necesitamos ahora es un subwoofer. Es decir, ¡un servidor web! Puedes configurar un servidor web real como Nginx o algo moderno como Caddy. Pero para el desarrollo local, el binario de Symfony puede ayudarnos. Corre:
symfony serve -d
Y... ¡tenemos un servidor web funcionando! ¡Vuelve!
La primera vez que ejecutes esto, es posible que te pida que ejecutes otro comando para configurar un certificado SSL, lo cual está bien porque entonces el servidor soporta https.
¡Momento de la verdad! Copia la URL, gira hacia tu navegador, aguanta la respiración y ¡woo! Hola página de bienvenida de Symfony 6... completa con extravagantes cambios de color cada vez que recargamos.
A continuación: conozcamos -y hagámonos amigos- del código dentro de nuestra aplicación, para poder desmitificar lo que hace cada parte. Luego codificaremos.
76 Comments

Vincent S. you're welcome!


If you're doing this in Windows & you run from WSL:
View your page at http(s)://localhost:8001 not http(s)://127.0.0.1:8001
This is because whether you create your project in WSL or not WSL, localhost will map correctly. The IP address from WSL will actually be something like 172.x.x.x not 127.x.x.x (try ip addr show in WSL)
The browser does not run from WSL, it runs from the Windows shell, and in that there is nothing running on 127.0.0.1
HTH

Yes, you're right. Windows WSL forces you to use localhost
instead of 127.0.0.1
.
Thanks for sharing it! Cheers!


Hello ,
i have a problem with Symfony\Component\ErrorHandler\ErrorHandler::handleFatalError(). I use php 8.4. So found article where says 'E_STRICT constant deprecated' , ok , but i can not find how to fix this . i don't want to downgrade my php version .

Hey @Doston-A
That's kinda weird, in theory Symfony 6 is compatible with PHP 8.4. Try running composer upgrade "symfony/*"
Cheers!


The error message is :PHP Deprecated: Constant E_STRICT is deprecated in /home/doston/Documents/VinilMix/vendor/symfony/error-handler/ErrorHandler.php on line 58
PHP Deprecated: Constant E_STRICT is deprecated in /home/doston/Documents/VinilMix/vendor/symfony/error-handler/ErrorHandler.php on line 76<br />
Hey Doston,
Where exactly do you see that? In the console output of the symfony serve
command? Anyway, I see you're on the latest stable PHP 8.4, which is great. Those messages are not errors but just deprecation warnings. That means that the project application should still be functioning; you can ignore those messages for learning purposes and continue following this course locally, it should not be a blocker for you. In case you want to deploy your project to production and allow your users to access it - I would recommend you to upgrade the dependencies first, as Diego suggested.
Cheers!


Victor , Hi ,
You are right , thanks you guys a lot , yes i continued the course and the error message is showing in every where , every console command, every twig environment. really i am afraid of to upgrade component because , I had experience with incompatibility between the article and the current version of the project and I spent a lot of time on it.
i know it is a part of coding and you learn a lot of things by this way, but when you are working at other working (not coding) on day, in evening i have little time to learn new somethings.
I am only was interested maybe someone know how to fixe this deprecation warnings. Of course i googled about it but i did not find any useful things.
Best regards,
Doston Asadov
Hey Doston,
I understand! First of all, you don't have to upgrade deps to try to fix it, you can just continue ignoring it.. but yeah, I understand that it may annoy you. You can try to suppress those warnings in your php.ini
config file with:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED
Restart the server just in case and warnigns should gone. That's a temporary solution, but should help. Just don't forget to return warnings back for your other (real) projects to avoid missing something important in them.
Or you can even try to supress them in your public/index.php
, add this in the beginning:
error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
Cheers!


i think 2 solution is sounds good and for temporary solution is good too.
you are the best !
Hey Doston,
For our course projects that you run locally, it should be good enough indeed. Just keep it in mind in case you decide to deploy it to production, then I would recommend you to do a proper fix by upgrading the dependencies :)
Cheers!


hi, Viktor
error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
is not helped me and in the end of course when i send get request for getting audio file , status code was 200 but body of response begings with PHP Deprecated: Constant E_STRICT is deprecated in /home/doston/Documents/VinilMix/vendor/symfony/error-handler/ErrorHandler.php on line 58<br />PHP Deprecated: Constant E_STRICT is deprecated in /home/doston/Documents/VinilMix/vendor/symfony/error-handler/ErrorHandler.php on line 76<br />
and songs data. So audio play is not worked, and I found solution.
I use Linux Ubuntu , i install other version of php, 7.2, 7.4, 8.0, 8.2, 8.3 and only with 8.3 the error was disappeared.
Cheers!
Hey Doston,
Ah really, that won't work indeed. Well, there's a dirty solution, you can open that file in vendors and add @
in front of all ini_set()/ini_get()
function calls, e.g.: @ini_set(...)
- this will suppress the errors. Though do any changes in the vendor/
is not recommended, that might be OK in your case if you use this project only for learning purposes locally. On real projects better never do this.
But your solution to switch to Ubuntu is even better and much robust.
Cheers!


I think you should start with basics - at least a checkout list:
- install PHP
- install composer
It's crucial for those who are new to Symfony and PHP
Hey Jan,
Thank you for your suggestion! Yeah, I agree, for newbies it might be crucial indeed!
Unfortunately, that's not that easy to cover this in this course. First of all, this is a course about Symfony, so we already suppose you know some PHP basics and so you already have PHP installed on your machine - I think most of our users hit this case. If you're new to PHP and don't know it at all - we would recommend you to learn PHP first instead of jumping into Symfony. We have some courses about PHP here in a separate track: https://symfonycasts.com/tracks/php . The same about Composer, you either have it installed and you know about it... or if not - please, check a separate course about it first: https://symfonycasts.com/screencast/composer .
Also, there's another problem with different platforms: MacOS, Windows, Linux... even different Linux distributions have their own different package managers and different ways to install PHP. That all complicates things a lot. If we will cover how to install it Mac in the screencast - it will be useful for Mac users only, but completely pointless for people on other platforms. That's why we do not cover such low lever things in the course about a completely different topic: Symfony introduction in this case.
And finally, if you experience any troubles to follow our courses - please, feel free to leave a comment below the video and our support team will help you!
I hope this helps and thanks for your understanding!
Cheers!


At my doctrine.yaml I have the following configuration:
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
I want to connect to 2 different databases with the following configuration:
dbal:
connections:
default_connection: default
default:
url: '%env(resolve:DATABASE_URL)%'
old_wtb:
url: '%env(resolve:DATABASE_URL_OLD_WTB)%'
This will give me the following error:
Invalid type for path "doctrine.dbal.connections.default_connection". Expected "array", but got "string"
When I delete the default_connection: default I get the following error:
>Unrecognized option "profiling_collect_backtrace" under "doctrine.dbal". Available options are "connections", "default_connection", "driver_schemes", "types".
How do I config this so I can connect to 2 databeses?
Hey Tim,
You almost nailed it, but mess up your configuration slightly. Try this one:
doctrine:
dbal:
default_connection: default
connections:
default:
url: '%env(resolve:DATABASE_URL)%'
old_wtb:
url: '%env(resolve:DATABASE_URL_OLD_WTB)%'
So as you see you have the wrong level for default_connection
.
Cheers!


Victor,
Is there a way I can reverse engineer the old_wtb database to entities? I found an article thats says to use the composer require symfony/orm-maker but it isn't supported anymore.
Hey Tim,
I think it should be in the core now, take a look at doctrine:mapping:import
command, it imports mapping information from an existing database. I suppose that's what you need.
Cheers!


I did try that with the following command: ./bin/console doctrine:mapping:import --em=old_wtb --path=src/Entity/OldWtb yaml
Now I get this error:
[critical] Error thrown while running command "doctrine:mapping:import --em=old_wtb --path='src/Entity/OldWtb' yaml". Message: "Property "jobofferalertuserqueue" in "ClassificationTag" was already declared, but it must be declared only once"
Meanwhile I also tried to connect to a third database. When I try the import command: ./bin/console doctrine:mapping:import --em=wp --path=src/Entity/Wp yaml
The following error shows:
"Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it."
This is my current config:
`doctrine:
dbal:
default_connection: default
connections:
default:
url: '%env(resolve:DATABASE_URL)%'
old_wtb:
url: '%env(resolve:DATABASE_URL_OLD_WTB)%'
wp:
url: '%env(resolve:DATABASE_URL_WP)%'
profiling_collect_backtrace: '%kernel.debug%'
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
mappings:
App:
is_bundle: false
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
old_wtb:
connection: old_wtb
mappings:
OldWtb:
is_bundle: false
dir: '%kernel.project_dir%/src/Entity/OldWtb'
prefix: 'App\Entity\OldWtb'
alias: OldWtb
wp:
connection: wp
mappings:
OldWtb:
is_bundle: false
dir: '%kernel.project_dir%/src/Entity/Wp'
prefix: 'App\Entity\Wp'
alias: Wp`
Hey Tim,
I bet you should run that command for a new entity to avoid conflicts... I would recommend you to create a completely new and empty entity file and import it there even if you have already imported some fields manually. Then later you will be able to merge the new autogenerated entity from that import with your existing entity. That's. the best strategy I think.
About the 2nd error - hm, not sure, probably try to check the version of the DB you're trying to connect, and make sure you set up the server version correctly in your Doctrine config file, or most probably in your DATABASE_URL value.
I hope that helps!
Cheers!


Hi Victor,
Thank you for your quick reply. How can I run the command for a new entity? "I bet you should run that command for a new entity " I thought this config should do that:dir: '%kernel.project_dir%/src/Entity/OldWtb'
prefix: 'App\Entity\OldWtb'
About the other error I did check the settings. I got these off my old project. But I will double check and try to debug.
Hey Tim,
you can do it with some workarounds I believe, e.g. you can just temporarily delete that ClassificationTag
in your project and run the command... Or if that command requires an entity - you can at least temporarily delete or comment out the problematic property there.
Cheers!


Hey Victor,
Thank you for your reply. Unfortuntaly the configuration above isn't working for me.
This is my full config at doctrine.yml:
doctrine:
dbal:
default_connection: default
connections:
default:
url: '%env(resolve:DATABASE_URL)%'
old_wtb:
url: '%env(resolve:DATABASE_URL_OLD_WTB)%'
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '16'
profiling_collect_backtrace: '%kernel.debug%'
orm:
auto_generate_proxy_classes: true
enable_lazy_ghost_objects: true
report_fields_where_declared: true
validate_xml_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
type: attribute
is_bundle: false
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
when@test:
doctrine:
dbal:
# "TEST_TOKEN" is typically set by ParaTest
dbname_suffix: '_test%env(default::TEST_TOKEN)%'
when@prod:
doctrine:
orm:
auto_generate_proxy_classes: false
proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies'
query_cache_driver:
type: pool
pool: doctrine.system_cache_pool
result_cache_driver:
type: pool
pool: doctrine.result_cache_pool
framework:
cache:
pools:
doctrine.result_cache_pool:
adapter: cache.app
doctrine.system_cache_pool:
adapter: cache.system
And this is the error I get:
Unrecognized option "profiling_collect_backtrace" under "doctrine.dbal". Available options are "connections", "default_connection", "driver_schemes", "types".
Can you see what's wrong?


I think I found it. The profiling_collect_backtrace: '%kernel.debug%' should also be indented another level.
doctrine:
dbal:
default_connection: default
connections:
default:
url: '%env(resolve:DATABASE_URL)%'
old_wtb:
url: '%env(resolve:DATABASE_URL_OLD_WTB)%'
profiling_collect_backtrace: '%kernel.debug%'
It was like this in my previously config:
doctrine:
dbal:
default_connection: default
connections:
default:
url: '%env(resolve:DATABASE_URL)%'
old_wtb:
url: '%env(resolve:DATABASE_URL_OLD_WTB)%'
profiling_collect_backtrace: '%kernel.debug%'
Hey Tim,
Good catch! I'm glad you were able to find it yourself :)
Most problems with config are about the wrong indentation. You can always leverage bin/console config:dump doctrine
command to double-check that every option is on the correct level.
Cheers!


Hi Victor,
I ran into a new issue. At my project I manually created a new entity to connect to my old_wtb. My doctrine.yaml is as following:
doctrine:
dbal:
default_connection: default
connections:
default:
url: '%env(resolve:DATABASE_URL)%'
old_wtb:
url: '%env(resolve:DATABASE_URL_OLD_WTB)%'
wp:
url: '%env(resolve:DATABASE_URL_WP)%'
profiling_collect_backtrace: '%kernel.debug%'
orm:
auto_generate_proxy_classes: true
enable_lazy_ghost_objects: true
default_entity_manager: default
entity_managers:
default:
connection: default
report_fields_where_declared: true
validate_xml_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
mappings:
App:
is_bundle: false
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
old_wtb:
connection: old_wtb
report_fields_where_declared: true
validate_xml_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
mappings:
OldWtb:
is_bundle: false
dir: '%kernel.project_dir%/src/Entity/OldWtb'
prefix: 'App\Entity\OldWtb'
alias: OldWtb
wp:
connection: wp
report_fields_where_declared: true
validate_xml_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
mappings:
OldWtb:
is_bundle: false
dir: '%kernel.project_dir%/src/Entity/Wp'
prefix: 'App\Entity\Wp'
alias: Wp
Company Entity
namespace App\Entity\OldWtb;
use App\Repository\OldWtb\CompanyRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CompanyRepository::class)]
class Company
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $companyName = null;
public function getId(): ?int
{
return $this->id;
}
public function getCompanyName(): ?string
{
return $this->companyName;
}
public function setCompanyName(string $companyName): static
{
$this->companyName = $companyName;
return $this;
}
}
Now at my controller I'm trying to dump the companies for the old_wtb and default Manager.
BaseController.php
namespace App\Controller;
use App\Entity\Company;
use App\Entity\OldWtb\Company as PreviousCompany;
class BaseController extends AbstractController
{ #[Route('/companies', name: 'get_company')]
public function getCompanies(Request $request, ManagerRegistry $managerRegistry)
{
$defaultEntityManager = $managerRegistry->getManager('default');
$currentCompanies = $defaultEntityManager->getRepository(Company::class)->findAll();
dump($currentCompanies);
$oldWtbEntityManager = $managerRegistry->getManager('old_wtb');
$oldCompanies = $oldWtbEntityManager->getRepository(PreviousCompany::class)->findAll();
dd($oldCompanies);
}
}
But I only see the default Manager Companies twice instead of the old_wtb companies and default companies.
If I dump the $defaultEntityManager and the $oldWtbEntityManager I can see that they are indeed different.
What's wrong?
Hey Tim,
Unfortunately, we don't have bandwidth to answer personal project related questions, and this topic is advanced and not covered by this tutorial.
My guess is that the default entity manager should be pointed to the subdirectory as well because right now it's literally linked to the global src/Entity/ folder which includes both your subdirectories: OldWtb and Wp. I would recommend you to use 3 separate folders like it's mentioned in the official docs, i.e. try to change the default entity manager prefix to src/Entity/Defaul/ for example. This way you will have 3 separate subfolders and will not have any overlapping.
I hope this helps and thank you for understanding!
Cheers!


Hi Victor,
I understand you don't have the bandwith to deep dive in all the questions. I thought the question could be of value for everyone that wants to have multiple database connections.
I did try to change the default entity manager prefix but then I had to change my entire code. But I found a solution!
At my project I did change the directory structure of the external Entities. So now I have my project entity folder like this: project/src/Entity
My Entity folder for the external Entities is Like this:
project/src/ExternalData/Entity/OldWtb
project/src/ExternalData/Repository/OldWtb
and
project/src/ExternalData/Entity/Wp
project/src/ExternalData/Repository/Wp
My config at project/config/packages/doctrine.yaml
is as following:
orm:
auto_generate_proxy_classes: true
enable_lazy_ghost_objects: true
default_entity_manager: default
entity_managers:
default:
connection: default
report_fields_where_declared: true
validate_xml_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
mappings:
App:
is_bundle: false
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
old_wtb:
connection: old_wtb
report_fields_where_declared: true
validate_xml_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
mappings:
OldWtb:
is_bundle: false
dir: '%kernel.project_dir%/src/ExternalData/Entity/OldWtb'
prefix: 'App\ExternalData\Entity\OldWtb'
alias: OldWtb
wp:
connection: wp
report_fields_where_declared: true
validate_xml_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
mappings:
Wp:
is_bundle: false
dir: '%kernel.project_dir%/src/ExternalData/Entity/Wp'
prefix: 'App\ExternalData\Entity\Wp'
alias: Wp
I hope this will help anyone in the future!
Hey Tim,
Yeah, your change makes sense too, as long as the paths are not overlapped - it should work well.
I'm glad to hear you found a working solution for you, and thanks for sharing it with others!
Cheers!
Hey, I wanna learn the framework - should I worry that Symfony 5 course has more videos?
Should I start with this one, and then check out topics that were covered in that course, or just go with this one and don't worry about that at all?
Hey Kamil,
If you want to start from scratch a new project - I would recommend to start with this Symfony 6 course. Btw, we're working on Symfony 7 intro course that will be started releasing soon, but you can definitely start with this one to not wait it. And yes, you can watch everything in this track, and fall back to the previous Symfony version to look for more content - it may have some differences, but usually we add video and script notes to mention it.
But in case you're planning to maintain a legacy Symfony version - thats probably a good idea to start with the version you will have to maintain for simplicity.
Cheers!


Has the way symfony console works changed since the filming of this tutorial? Running symfony new mixed_vinyl
generates a different set of files to the ones show in the video. Running git show --name-only
results in:
composer.json
composer.lock
config/bundles.php
symfony.lock
vendor/autoload.php
vendor/autoload_runtime.php
vendor/bin/patch-type-declarations
vendor/bin/var-dump-server
vendor/bin/yaml-lint
vendor/composer/ClassLoader.php
vendor/composer/InstalledVersions.php
vendor/composer/LICENSE
vendor/composer/autoload_classmap.php
vendor/composer/autoload_files.php
vendor/composer/autoload_namespaces.php
vendor/composer/autoload_psr4.php
vendor/composer/autoload_real.php
vendor/composer/autoload_static.php
vendor/composer/installed.json
vendor/composer/installed.php
vendor/composer/platform_check.php
vendor/psr/cache
vendor/psr/container
vendor/psr/event-dispatcher
vendor/psr/log
vendor/symfony/cache
and running symfony serve
give a "Page not found" message when visiting https://127.0.0.1:8000/
What commands need to be run so that I can follow along with this tutorial?
Symfony cli version: 5.5.6
Hey Danny,
First of all, we do recommend you to download the course code for this course on any video page - see "Download" button - and start from the start/ directory there. You will also find a README.md file inside with the detailed instructions about what command you need to run to bootstrap the course project locally. This way you will have the exact same versions we use in this course.
But if you want to follow this course on a newer Symfony version - that's up to you! But keep in mind some changes, depends on the version difference. Also, make sure you allow Composer to execute some plugins - otherwise Symfony Flex will not able to execute some recipes of dependencies and you really may miss some files unless copy/paste them manually.
Cheers!
Cheers!
Just for suggestion, ın installation part, there is a link . BUt that link does not show PHP version requirement.
Hey Mahmut,
Are you talking about this Symfony CLI download link? https://symfony.com/download Or what PHP version requirement are you talking about? Could you explain more please?
Cheers!
Hi Dear Victor,
I am really happy to see your message. Such community is realy nice to imrove ourselves.
For this topic, yes I mentioned that link. Actually, when we follow videos, I am not ( since I am junior, newbie) able to create projects well. I read other documentations about symfony then I was successfull.
Maybe if there can be step by step installation and requirements , will be perfect. because when I follow this video, ı was not aware of php version . so for example, maybe we can mention how to run on apache web server under /var/www/html etc.
other problem for example that ı encounter, I was doing my project in centos and ı needed to create .htaccess file to run my route.
Because http://172.22.111.7/index.bgp/my_route was working but http://172.22.111.7/my_route did not work etc.
thank you regards,
Hey Mahmut,
Thank you for your feedback! Yes, we do not talk about running this website on a real web server like Apache etc. mostly because Symfony makes it much simpler with the built-in web server we show in this course. Topic about running Symfony websites on a real web server deserves a separate course. Mostly, it's about production because configuring it for using locally does not make much sense thanks to the Symfony built-in web server. If you're looking into deploying a Symfony app to production - we have a separate course about it, see it here: https://symfonycasts.com/screencast/ansistrano - but mostly we talk about Nginx there instead of Apache, that is more "mainstream" lately :) Also, you can read more about recommended web server config in the official Symfony docs: https://symfony.com/doc/current/setup/web_server_configuration.html
About PHP version - yeah, we might not mention it in the video probably.. but you can see the minimum required PHP version for this course code on the "Versions" tab below the video on every video page - there's an actual composer.json file with all the main dependencies versions including PHP.
So, this is an intro course about Symfony, so we definitely don't want to complicate things too much for people who just want to start getting acquainted with Symfony, that topic deserve a separate more specific course :)
Btw, every course project code you downloaded will have a README file with all the necessary instructions what you have to boot the course project locally. If you miss it - that makes sense it was hard to configure the project locally for you.
Anyway, good catch on official Symfony docs. That's also a good spot to know more about Symfony, and it covers much more things that were not mentioned in the course.
I hope this helps!
Cheers!


My webserver is returning a 404 - what on earth?
loading (as per command line):
https://127.0.0.1:8000
running symfony serve -d
chrome and firefox give "This site can’t be reached"
I looked at the files, they all apear to be there.
is there a troubleshooting guide for this or a way to find the issue?


ok, I just tried localhost (instead of 127....) and it worked. that's weird.
Hey Cameron,
Happy to hear you were able to find a workaround yourself, great job!
Yeah, sometimes it might be important, especially when you use Docker, or Windows also can give you some issues like this. What OS are you on btw?
I suppose if localhost works for you - great, just use it further. Btw, when you start the Symfony web server, i.e. run symfony serve
- it should output you the correct URL. I wonder, if that a localhost URL or https://127.0.0.1:8000 for you?


I'm on windows 11, using WSL ubuntu. yes, it shows 127.0.0.1:800 - weird? thanks for the help.
Hey Cameron,
Ah, Windows + WSL, that makes sense unfortunately, I heard that has some problems with 127.0.0.1 and you have to use localhost instead. I think nothing much you can do with it, just remember to use localhost instead :)
Cheers!


Is there any way to get symfony serve to listen on an address other than localhost? I have symfony set up in a VM, and would like to connect from Firefox running on a physical PC. If not, an ssh tunnel works as a work-around.
Hey Kevin,
I'm not sure it's possible, probably you need to set up a real web server for this, Symfony binary usually is used for local development. Though, I think you need to think about somehow to open that port to your VM so you could run the Sf binary there but connect to it from your local machine (outside of VM). I think it should be possible, maybe try to google some info on the internet.
Cheers!


Hi, I want to install the Symfony CLI on Windows 10 but would like to avoid installing Scoop and use the downloadable binaries instead. However if I execute the symfony.exe file I get the alert that I need to download an app for this task and whether I would like to search for that app in the App Store. After confirming that nothing happens.
What am I doing wrong or how do I go about installing Symfony without Scoop?


You can install it manually by moving the binary to a program folder such as this:
C:\Users\%USERNAME%\AppData\Local\Programs
Then copy the path to the folder where the .exe is and add it to your PATH
Windows > Search "env" > Edit the system environment variables > Edit Variables > Select "Path" > Add New > Paste and Apply

Hey Robert J.
My first suggestion is to user Windows WSL 2. It's an embedded Linux environment which works pretty well (that's what I use actually)
If you don't want to change to WSL, I found this SO answer which may help you out: https://stackoverflow.com/a...
I hope it helps. Cheers!

"Houston: no signs of life"
Start the conversation!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=8.1",
"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.4.5
"symfony/framework-bundle": "6.0.*", // v6.0.4
"symfony/monolog-bundle": "^3.0", // v3.7.1
"symfony/runtime": "6.4.3", // v6.4.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
}
}
Thank you for this tutorial and all the content !
Merci beaucoup pour ce travail et toutes ces informations !
Vincent