Chapters
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Guardemos nuestro progreso hasta ahora. Voy a limpiar la pantalla y ejecutaré:
git status
Interesante: Hay algunos archivos nuevos aquí que yo no creé. No te preocupes: Vamos a hablar precisamente de eso en el siguiente capítulo. Agrega todo con:
git add .
Normalmente... Este comando puede ser peligroso - accidentalmente podríamos agregar algunos archivos que no queremos al commit! Afortunadamente, nuestro proyecto viene con un archivo .gitignore
precargado que ignora cosas importantes como vendor/
y otras rutas de las cuales hablaremos más tarde. Por ejemplo, var/
contiene el caché y los archivos de logs. El punto es, que Symfony nos cuida la espalda.
Guarda los cambios con:
git commit -m "Lo estamos haciendo en grande con esto de Symfony"
Hola comando bin/console
Puedes interactuar de dos maneras diferentes con tu aplicación de Symfony. La primera es al cargar una página en tu navegador. La segunda es con un útil comando llamado bin/console
. En tu terminal, ejecuta:
php bin/console
¡Orale! Este comando enlista un montón de cosas diversas que puedes hacer con eso, incluidas múltiples herramientas de depuración. Ahora, para desmitificar este asunto un poco, existe literalmente
un directorio bin/
en nuestra aplicación con un archivo llamado console
adentro. Así que esta cosa bin/console
no es un comando global que se ha instalado en nuestro sistema: estamos, literalmente ejecutando un archivo PHP.
El comando bin/console
puede hacer muchas cosas - y descubriremos mis características favoritas a lo largo del camino. Por ejemplo, ¿Quieres ver un listado para cada ruta en tu aplicación? Ejecuta:
php bin/console debug:router
¡Sip! Ahí están nuestras dos rutas... además de otra que Symfony agrega automáticamente durante el desarrollo.
La herramienta bin/console
contiene muchos comandos útiles como este. Pero la lista de comandos que soporta no es estática. Nuevos comandos pueden ser agregados por nosotros... O por nuevos paquetes que instalemos en nuestro proyecto. Este es mi "no tan sutil" presagio.
A continuación: Hablemos de Symfony Flex, alias con Composer y el sistema de recetas. Básicamente, las herramientas que hacen a Symfony verdaderamente único.
14 Comments
Hi Rizky, the sensiolabs/security plugin has been deprecated, you
have to use the php-local-security-checker package,whcih serves the same
purpose. https://github.com/fabpot/l...
Hey Rizky,
It's recommended to use "symfony security:check" command instead. Otherwise, try to upgrade the "sensiolabs/security-checker" package with Composer to the latest, but if you're on a not maintained Symfony version - you would need to upgrade Symfony packages in your project first. So I'd recommend you to go with "symfony security:check".
Cheers!
Hey Victor!
Is it possible to run symfony security: check after executing compsoer install as described in the instructions where the author worked with security: check
Hey Azar,
Good question! Actually, it is possible, for example with this syntax:
{
"scripts": {
"auto-scripts": {
// ...
"symfony security:check": "script"
},
},
}
I.e. you should use "script" instead of "symfony-cmd". But it will also mean that you always have installed symfony CLI on the machine where you run any Composer operations in your project, otherwise it will fail.
Another solution - just add an extra step to your CI to run that "symfony security:check" as a separate step instead of doing this during Composer operations like install or update :)
Cheers!
Could you tell in more detail how exactly to do this through CI, or where to read :)
Hey Azar,
Well, you just need to download that "symfony" CLI on your CI and add a new step to your tests steps that will execute "symfony security:check" - pretty simple if you have a CI :) If you don't, take a look at: https://symfonycasts.com/sc... about a possible example how to configure a CI first. Or read the docs about GitHub Actions.
I hope this helps!
Cheers!
Hi,
Is it possible to encode a symfony project with ionCube without breaking it?
Hey Niki,
I know very little about ionCube, but yes, I suppose it should be possible as long as you warm up the cache before encoding. Basically, Symfony app should generate all the necessary cache and compile all necessary files during the cache:warmup command. After this, you can run Symfony app on read-only filesystem and it should just work. Of course, it also depend on you and your code. I suppose you should avoid writing to the filesystem in your code, only read operations, or probably use a different cache providers like Memcache or Redis, etc.
I hope this helps, unfortunately, I can't say more about it.
Cheers!
Hi Ryan, totaly unrelated question ... but how do you do to display a dotted line after each instruction in your command line interface ?
This is super useful !
Finally got something working :)<br /># ~/.zshrc<br /># <<< dotted line between command >>><br />setopt promptsubst<br />PS1=$'%F{250}${(r:$COLUMNS::╌:)}%f'$PS1<br />
Hey Mickael!
Glad you was able to figure it out yourself! Ryan *just* started using this new terminal theme - he's using zsh with ohmyzsh. Inside ohmyzsh, he's using the "af-magic" theme with some customizations. Here's my custom theme file - https://gist.github.com/wea... - it's the "af-magic" theme but (mostly) with a few features *removed* to keep his screen simpler.
I hope that helps :)
Cheers!
In Chapter 01 the Symfony executable is downloaded. Is there a reason why in this chapter php bin/console
is used instead of symfony console
other than that it might be shorter to type?
Hey Jason A.!
Excellent question! It is mostly to introduce concepts little-by-little. By showing php bin/console
, it's easy to show that you're just executing a normal, boring, physical file. But symfony console
looks a bit more "magical", even though it's technically a lot more useful (because you can manage PHP versions through it, run commands un "tunneled" SymfonyCloud environments etc). I'm planning to introduce doing more things with the symfony
command little-by-little - it'll especially be important when we talk about databases.
Cheers!
"Houston: no signs of life"
Start the conversation!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.3.0 || ^8.0.0",
"ext-ctype": "*",
"ext-iconv": "*",
"easycorp/easy-log-handler": "^1.0.7", // v1.0.9
"sensio/framework-extra-bundle": "^6.0", // v6.2.1
"symfony/asset": "5.0.*", // v5.0.11
"symfony/console": "5.0.*", // v5.0.11
"symfony/debug-bundle": "5.0.*", // v5.0.11
"symfony/dotenv": "5.0.*", // v5.0.11
"symfony/flex": "^1.3.1", // v1.21.6
"symfony/framework-bundle": "5.0.*", // v5.0.11
"symfony/monolog-bundle": "^3.0", // v3.5.0
"symfony/profiler-pack": "*", // v1.0.5
"symfony/routing": "5.1.*", // v5.1.11
"symfony/twig-pack": "^1.0", // v1.0.1
"symfony/var-dumper": "5.0.*", // v5.0.11
"symfony/webpack-encore-bundle": "^1.7", // v1.8.0
"symfony/yaml": "5.0.*" // v5.0.11
},
"require-dev": {
"symfony/profiler-pack": "^1.0" // v1.0.5
}
}
php bin/console security:check
The web service failed for an unknown reason (HTTP 403).
T_T how to fix it?