Chapters
-
Course Code
Subscribe to download the code!Compatible PHP versions: ^7.1.3
Subscribe to download the code!Compatible PHP versions: ^7.1.3
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
Setting up with the Symfony Local Web Server
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Yo friends! It's file upload time! Woo! We are going to absolutely crush this topic... yea know... because file uploads are a critical part of the Internet. Where would we be if we couldn't upload selfies... or videos of Victor's cat... or SPAM our friends with memes!?!?! That's not a world I want to live in.
But... is uploading a file really that hard: add a file input to a form, submit, move the file onto your filesystem and... done! Meme unlocked! Well... that's true... until you start thinking about storing files in the cloud, like S3. Oh, and don't forget to add validation to make sure a user can't upload any file type - like an executable or PHP script! And you'll need to make sure the filename is unique so it doesn't overwrite other files... but also... it's kind of nice to keep the original filename... so it's not just some random hash if the user downloads it later. Oh, and once it's uploaded, we'll need a way to link to that file... except if you need to do a security check before letting the user download the file. Then you'll need to handle things in a totally different way.
Um... so wow! Things got complex! That's awesome! Because we're going to attack all of this... and more.
Downloading the Course Code
If you want to upload the maximum knowledge into your brain... you should definitely download the course code from this page and code along with me. After unzipping the file, you'll find a start/
directory that has the same code you see here. Open the README.md
file for all the setup details... and a few extras.
The last setup step in our tutorials is usually to open a terminal, move into the project and run:
php bin/console server:run
to start the built in web server. You can totally do this. But, but, but! I want to show you a new tool that I'm loving: the Symfony local web server.
Downloading the Symfony Local Web Server
Find your browser and go to https://symfony.com/download. The Symfony local web server - or Symfony "client" - is a single, standalone file that is full of superpowers. At the top, you'll see instructions about how to download it. These steps are different depending on your operating system - but it should auto-select the right one.
For me, I'll copy this curl command, find my terminal, paste and enter! This downloaded a single executable file called symfony
. To make sure I can type that command from anywhere, I'll move this into a global bin
directory. By the way, you only need to do these steps once on your computer... so you're done forever!
Unless we've mucked things up, we should now be able to run this from anywhere: try it!
symfony
Say hello to the Symfony CLI! It lists the most popular commands, but there are a lot more - run:
symfony help
Woh. We'll talk more about this tool in another tutorial. But, to start a local web server, just say:
symfony serve
Ah. The first time you run this, you'll get an error about running: symfony server:ca:install
. Let's do that:
symfony server:ca:install
You'll probably need to type in your admin password. This command installs a local SSL certificate authority... which is awesome because when we run symfony serve
, it creates a local web server that supports https! Woh! We get free https locally! Sweet!
Find your browser and go to https://127.0.0.1:8000
- or localhost, it's the same thing. Say hello to The SpaceBar! This is the app we've been building in our Symfony 4 series: a news site for space-traveling friends from across the galaxy.
Try logging in with admin1@thespacebar.com
and password engage
. Then go to /admin/article
.
This is the admin section for the articles on the site. Each article has an image... but until now, that image has basically been hardcoded. Click to edit one of the articles. Our first goal is clear: add a file upload field to this form so we can upload the article image, and then render that on the frontend.
But we're going to keep things simple to start... and take a deep and wonderful look into the fundamentals of how files are uploaded on the web and how that looks inside Symfony. Let's go!
60 Comments
... 85 % free space and 95 % free inodes ...
It only runs as root.
As a regular user, it creates the log files inside $HOME/.symfony/log, but it cannot start the server ...
Hey Facundo,
Were you able to got it working? Probably "chown" the log file to the current user will solve the problem with permissions. I installed symfony CLI w/o sudo and it works for me. If you still have any problems with it - please, share some output so we see more context.
Cheers!
Actually, the log directory and files are created with my user.
Here is the sequence of what I do, and the result:
$ symfony server:start -d
[WARNING] run "symfony server:ca:install" first if you want to run the web server with TLS support, or use "--no-tls"
to avoid this warning
Impossible to go to the background
Continue in foreground
WARNING Web Server log file cannot be tailed: unable to watch log file: no space left on device
no space left on device
Inside my $HOME/.symfony/log:
$ ls -l
total 8
drwxr-xr-x 2 facundo facundo 4096 Sep 23 10:14 355fcc099c030d9fdf46ccacf80a13a5c57d076e
-rw-r--r-- 1 facundo facundo 441 Sep 23 10:14 355fcc099c030d9fdf46ccacf80a13a5c57d076e.log
ls -l 355fcc099c030d9fdf46ccacf80a13a5c57d076e/
-rw-r--r-- 1 facundo facundo 0 Sep 23 10:14 53fb8ec204547646acb3461995e4da5a54cc7575.log
As you can see, all files and directories are created with my running user.
I even tried changing permissions to 777, but with the same result.
- freespace on disk is about 85%
- free inodes is about 95 %
- symfony cli installed with my running user
- before yesterday's update it was all runing ok
- running as root seems to work ok
- o.s. is Debian 10.5
- php version is 7.3.19
- symfony cli version is (2020-09-22T10:45:38+0000 - stable)
Is there any other test / info that might help ?
Thanks.
Hey Facundo ariel P.!
Yea, this looks super weird - definitely like a bug. And one key thing you said is that it worked *before* the update (so, I'm guessing it worked when you had 4.18.4 of the symfony binary and now 4.19.0 is broken). I'd open an issue with this info here - https://github.com/symfony/cli
Unfortunately, the symfony binary is a small piece of not-open source code... so even I can't dive into it and debug what's going on.
Cheers!
I've try it in a brand new installed system and it works.
I think it might be something with my installation. The rare thing is I think I did not change anything in the middle.
I'll keep trying to solve it.
Thanks.
Let us know if you keep getting problems
Hey Ricardo,
Are you talking about Symfony console, i.e. bin/console? If so - you're on the wrong way, you need to use Symfony CLI client that we use in this course. It's a standalone application that you need to download from https://symfony.com/download - find a way to do this for your OS, and then follow hints from the installer. When you install it and move to the "/usr/local/bin/" - you can run the server with "symfony serve" command. And "symfony server:ca:install" command will be available as well for you.
P.S. So the "bin/console" Symfony Console component and the new Symfony CLI client are different things :)
Cheers!
Hey Victor,
Had the Symfony CLI installed, ran self-update, all good, ran the symfony serve command and got that error. Couldn't figure out what was going on so I downloaded again the Symfony Cli and this time it worked. Don't know why it didn't work the first time but well, at least it's working now.
Thanks for the help.
Cheers
Hey Ricardo manuel de faria silva gonçalves!
Hmm, super weird! Good though to just reinstall from scratch - it indeed could have been some legitimate issue with the library :).
Cheers!
I'm getting too many errors, it would be awesome if you could post a link to the working starter code so that we can watch it without worrying about errors.
When I do a composer installation, I get too many errors.
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
Your lock file does not contain a compatible set of packages. Please run composer update.
Problem 1
- Root composer.json requires php ^7.1.3 but your php version (8.3.2) does not satisfy that requirement.
Problem 2
- doctrine/annotations is locked to version 1.10.1 and an update of this package was not requested.
- doctrine/annotations 1.10.1 requires php ^7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 3
- doctrine/cache is locked to version 1.10.0 and an update of this package was not requested.
- doctrine/cache 1.10.0 requires php ~7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 4
- doctrine/collections is locked to version 1.6.4 and an update of this package was not requested.
- doctrine/collections 1.6.4 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 5
- doctrine/common is locked to version 2.12.0 and an update of this package was not requested.
- doctrine/common 2.12.0 requires php ^7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 6
- doctrine/dbal is locked to version v2.9.3 and an update of this package was not requested.
- doctrine/dbal v2.9.3 requires php ^7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 7
- doctrine/doctrine-bundle is locked to version 1.10.2 and an update of this package was not requested.
- doctrine/doctrine-bundle 1.10.2 requires php ^5.5.9|^7.0 -> your php version (8.3.2) does not satisfy that requirement.
Problem 8
- doctrine/doctrine-migrations-bundle is locked to version v2.0.0 and an update of this package was not requested.
- doctrine/doctrine-migrations-bundle v2.0.0 requires php ^7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 9
- doctrine/event-manager is locked to version 1.1.0 and an update of this package was not requested.
- doctrine/event-manager 1.1.0 requires php ^7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 10
- doctrine/inflector is locked to version 1.3.1 and an update of this package was not requested.
- doctrine/inflector 1.3.1 requires php ^7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 11
- doctrine/instantiator is locked to version 1.3.0 and an update of this package was not requested.
- doctrine/instantiator 1.3.0 requires php ^7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 12
- doctrine/migrations is locked to version v2.0.0 and an update of this package was not requested.
- doctrine/migrations v2.0.0 requires php ^7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 13
- doctrine/orm is locked to version v2.7.2 and an update of this package was not requested.
- doctrine/orm v2.7.2 requires php ^7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 14
- doctrine/persistence is locked to version 1.3.7 and an update of this package was not requested.
- doctrine/persistence 1.3.7 requires php ^7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 15
- doctrine/reflection is locked to version 1.2.1 and an update of this package was not requested.
- doctrine/reflection 1.2.1 requires php ^7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 16
- nexylan/slack is locked to version v2.2.0 and an update of this package was not requested.
- nexylan/slack v2.2.0 requires php ^7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 17
- nexylan/slack-bundle is locked to version v2.1.0 and an update of this package was not requested.
- nexylan/slack-bundle v2.1.0 requires php ^7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 18
- ocramius/proxy-manager is locked to version 2.1.1 and an update of this package was not requested.
- ocramius/proxy-manager 2.1.1 requires php ^7.1.0 -> your php version (8.3.2) does not satisfy that requirement.
Problem 19
- php-http/cache-plugin is locked to version 1.6.0 and an update of this package was not requested.
- php-http/cache-plugin 1.6.0 requires php ^5.4 || ^7.0 -> your php version (8.3.2) does not satisfy that requirement.
Problem 20
- php-http/client-common is locked to version 1.9.1 and an update of this package was not requested.
- php-http/client-common 1.9.1 requires php ^5.4 || ^7.0 -> your php version (8.3.2) does not satisfy that requirement.
Problem 21
- php-http/discovery is locked to version 1.6.1 and an update of this package was not requested.
- php-http/discovery 1.6.1 requires php ^5.5 || ^7.0 -> your php version (8.3.2) does not satisfy that requirement.
Problem 22
- php-http/httplug-bundle is locked to version 1.14.0 and an update of this package was not requested.
- php-http/httplug-bundle 1.14.0 requires php ^5.5 || ^7.0 -> your php version (8.3.2) does not satisfy that requirement.
Problem 23
- php-http/logger-plugin is locked to version 1.1.0 and an update of this package was not requested.
- php-http/logger-plugin 1.1.0 requires php ^5.4 || ^7.0 -> your php version (8.3.2) does not satisfy that requirement.
Problem 24
- php-http/message is locked to version 1.7.2 and an update of this package was not requested.
- php-http/message 1.7.2 requires php ^5.4 || ^7.0 -> your php version (8.3.2) does not satisfy that requirement.
Problem 25
- php-http/stopwatch-plugin is locked to version 1.2.0 and an update of this package was not requested.
- php-http/stopwatch-plugin 1.2.0 requires php ^5.4 || ^7.0 -> your php version (8.3.2) does not satisfy that requirement.
Problem 26
- phpdocumentor/reflection-docblock is locked to version 4.3.0 and an update of this package was not requested.
- phpdocumentor/reflection-docblock 4.3.0 requires php ^7.0 -> your php version (8.3.2) does not satisfy that requirement.
Problem 27
- phpdocumentor/type-resolver is locked to version 0.4.0 and an update of this package was not requested.
- phpdocumentor/type-resolver 0.4.0 requires php ^5.5 || ^7.0 -> your php version (8.3.2) does not satisfy that requirement.
Problem 28
- symfony/asset is locked to version v4.2.3 and an update of this package was not requested.
- symfony/asset v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 29
- symfony/cache is locked to version v4.2.3 and an update of this package was not requested.
- symfony/cache v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 30
- symfony/config is locked to version v4.2.3 and an update of this package was not requested.
- symfony/config v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 31
- symfony/console is locked to version v4.2.3 and an update of this package was not requested.
- symfony/console v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 32
- symfony/contracts is locked to version v1.0.2 and an update of this package was not requested.
- symfony/contracts v1.0.2 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 33
- symfony/debug is locked to version v4.2.3 and an update of this package was not requested.
- symfony/debug v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 34
- symfony/dependency-injection is locked to version v4.2.3 and an update of this package was not requested.
- symfony/dependency-injection v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 35
- symfony/doctrine-bridge is locked to version v4.2.3 and an update of this package was not requested.
- symfony/doctrine-bridge v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 36
- symfony/event-dispatcher is locked to version v4.2.3 and an update of this package was not requested.
- symfony/event-dispatcher v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 37
- symfony/filesystem is locked to version v4.2.3 and an update of this package was not requested.
- symfony/filesystem v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 38
- symfony/finder is locked to version v4.2.3 and an update of this package was not requested.
- symfony/finder v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 39
- symfony/form is locked to version v4.2.3 and an update of this package was not requested.
- symfony/form v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 40
- symfony/framework-bundle is locked to version v4.2.3 and an update of this package was not requested.
- symfony/framework-bundle v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 41
- symfony/http-foundation is locked to version v4.2.3 and an update of this package was not requested.
- symfony/http-foundation v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 42
- symfony/http-kernel is locked to version v4.2.3 and an update of this package was not requested.
- symfony/http-kernel v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 43
- symfony/inflector is locked to version v4.2.3 and an update of this package was not requested.
- symfony/inflector v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 44
- symfony/intl is locked to version v4.2.3 and an update of this package was not requested.
- symfony/intl v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 45
- symfony/options-resolver is locked to version v4.2.3 and an update of this package was not requested.
- symfony/options-resolver v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 46
- symfony/process is locked to version v4.2.3 and an update of this package was not requested.
- symfony/process v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 47
- symfony/property-access is locked to version v4.2.3 and an update of this package was not requested.
- symfony/property-access v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 48
- symfony/property-info is locked to version v4.2.3 and an update of this package was not requested.
- symfony/property-info v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 49
- symfony/routing is locked to version v4.2.3 and an update of this package was not requested.
- symfony/routing v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 50
- symfony/security-bundle is locked to version v4.2.3 and an update of this package was not requested.
- symfony/security-bundle v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 51
- symfony/security-core is locked to version v4.2.3 and an update of this package was not requested.
- symfony/security-core v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 52
- symfony/security-csrf is locked to version v4.2.3 and an update of this package was not requested.
- symfony/security-csrf v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 53
- symfony/security-guard is locked to version v4.2.3 and an update of this package was not requested.
- symfony/security-guard v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 54
- symfony/security-http is locked to version v4.2.3 and an update of this package was not requested.
- symfony/security-http v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 55
- symfony/serializer is locked to version v4.2.3 and an update of this package was not requested.
- symfony/serializer v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 56
- symfony/stopwatch is locked to version v4.2.3 and an update of this package was not requested.
- symfony/stopwatch v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 57
- symfony/templating is locked to version v4.2.3 and an update of this package was not requested.
- symfony/templating v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 58
- symfony/translation is locked to version v4.2.3 and an update of this package was not requested.
- symfony/translation v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 59
- symfony/twig-bridge is locked to version v4.2.3 and an update of this package was not requested.
- symfony/twig-bridge v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 60
- symfony/twig-bundle is locked to version v4.2.3 and an update of this package was not requested.
- symfony/twig-bundle v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 61
- symfony/validator is locked to version v4.2.3 and an update of this package was not requested.
- symfony/validator v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 62
- symfony/var-exporter is locked to version v4.2.3 and an update of this package was not requested.
- symfony/var-exporter v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 63
- symfony/web-server-bundle is locked to version v4.2.3 and an update of this package was not requested.
- symfony/web-server-bundle v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 64
- symfony/yaml is locked to version v4.2.3 and an update of this package was not requested.
- symfony/yaml v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 65
- webmozart/assert is locked to version 1.4.0 and an update of this package was not requested.
- webmozart/assert 1.4.0 requires php ^5.3.3 || ^7.0 -> your php version (8.3.2) does not satisfy that requirement.
Problem 66
- zendframework/zend-code is locked to version 3.3.1 and an update of this package was not requested.
- zendframework/zend-code 3.3.1 requires php ^7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 67
- zendframework/zend-eventmanager is locked to version 3.2.1 and an update of this package was not requested.
- zendframework/zend-eventmanager 3.2.1 requires php ^5.6 || ^7.0 -> your php version (8.3.2) does not satisfy that requirement.
Problem 68
- doctrine/data-fixtures is locked to version v1.3.1 and an update of this package was not requested.
- doctrine/data-fixtures v1.3.1 requires php ^7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 69
- doctrine/doctrine-fixtures-bundle is locked to version 3.1.0 and an update of this package was not requested.
- doctrine/doctrine-fixtures-bundle 3.1.0 requires php ^7.1 -> your php version (8.3.2) does not satisfy that requirement.
Problem 70
- fzaninotto/faker is locked to version v1.8.0 and an update of this package was not requested.
- fzaninotto/faker v1.8.0 requires php ^5.3.3 || ^7.0 -> your php version (8.3.2) does not satisfy that requirement.
Problem 71
- symfony/debug-bundle is locked to version v4.2.3 and an update of this package was not requested.
- symfony/debug-bundle v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 72
- symfony/dotenv is locked to version v4.2.3 and an update of this package was not requested.
- symfony/dotenv v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 73
- symfony/maker-bundle is locked to version v1.11.3 and an update of this package was not requested.
- symfony/maker-bundle v1.11.3 requires php ^7.0.8 -> your php version (8.3.2) does not satisfy that requirement.
Problem 74
- symfony/monolog-bridge is locked to version v4.2.3 and an update of this package was not requested.
- symfony/monolog-bridge v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 75
- symfony/var-dumper is locked to version v4.2.3 and an update of this package was not requested.
- symfony/var-dumper v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 76
- symfony/web-profiler-bundle is locked to version v4.2.3 and an update of this package was not requested.
- symfony/web-profiler-bundle v4.2.3 requires php ^7.1.3 -> your php version (8.3.2) does not satisfy that requirement.
Problem 77
- doctrine/cache 1.10.0 requires php ~7.1 -> your php version (8.3.2) does not satisfy that requirement.
- doctrine/doctrine-cache-bundle 1.3.5 requires doctrine/cache ^1.4.2 -> satisfiable by doctrine/cache[1.10.0].
- doctrine/doctrine-cache-bundle is locked to version 1.3.5 and an update of this package was not requested.
Hey Sujal,
We're sorry to hear you're experiencing problems running this course! Seems you're trying to run this course on a newer PHP version 8.3.2 while it works only on PHP 7. Unfortunately, this is a legacy PHP 7 course and you had to see a warning when downloading the course code. To run this course project code, you either need to downgrade your PHP version to PHP 7.x (or install a legacy PHP 7 along with your current PHP 8.3 version), or you can use a virtualization tool like Docker to run the legacy PHP version in a container, or you need to upgrade dependencies first that will support PHP 8 - but this last option will require more work from your side, as the upgrade may lead some BC breaks.
We plan to rerecord this course with the newer dependencies, but I can't tell you when it might be released, it's a low priority for us now.
I hope my advice helps you to start this course!
Cheers!
Hi,
This is more of a general question, but what's the recommended way of getting set up with these older tutorials? My laptop is on php 8 now and I get all sorts of errors with I do composer install.
Hey there,
That's a good question. Usually we upgrade our tutorials so they can work with newer PHP versions but that's not always possible, and this is one of those cases, that's why we advertise this tutorial is compatible only with PHP 7. What you can do is to also install PHP 7 in your local machine. If you're using Docker, that's a trivial task to do :)
Cheers!
Hello, I just changed my operating system from Windows 10 to Ubuntu! (quite a difference in performance by the way).
The problem is that when I install the symfony certificate to have the https, it no longer works, I get a "NET: ERR_CERT_AUTHORITY_INVALID" with the message "Your connection is not private".
How could I fix this problem?
EDIT : OKay, fixed. the problem was that I seemed to be missing a very important package: the 'certutil'. Everything is working now!
How can I enable xdebug with "symfony serve" command?
Hey Team P.!
Do you mean just "make sure it's enabled?" or for actual breakpoint debugging? If it's about the first question, the Symfony binary is pretty smart about finding various PHP binaries on your system (check symfony local:php:list
) and you can choose between which version to use with a .php-version file.
If you're talking about breakpoint debugging, there shouldn't be any special setup - but check this out for details - https://github.com/symfony/cli/issues/50 - and let me know if it helps.
Cheers!
I've just upgraded to the last version, and now I got
"Impossible to go to the background Continue in foreground
WARNING Web Server log file cannot be tailed: unable to watch log file: no space left on device
no space left on device "
in all my projects.
Ideas ?
Hey Facundo ariel P.
WARNING Web Server log file cannot be tailed: unable to watch log file: no space left on device
no space left on device "
That warning makes me think that you ran out of disk space in your computer? Can you double-check that please
And, about the other message Impossible to go to the background Continue in foreground
I got it too some times and I fix it by restarting the web server
Cheers!
how to set server name? Namely name that used in routing annotation.
Hey Michael de`Oz
What server name are you speaking about? Is it about host name option? you can find some information here https://symfony.com/doc/cur...
or it's something else?
Cheers!
Hello, i don't know where ask the question.
When i learned for the first time how to uploading file, it was recommended by Fabien Potencier to create an entity for the file and manage the UploadeFile class in the entity with doctrine events, for example App\Entity\Image. Today, i always follow this paradigm for my apps and manage all the files as mapped relations with Doctrine, so the approach of this tutorial perturbs me. Do you consider is not a good practise ? if yes, why ?
Source (fifth item)
Hey Jean M.!
I just saw your question over on the other chapter and replied :). https://symfonycasts.com/sc...
Cheers!
Hello !
The installation went well. But in my browser I have a message saying that this certificate is not safe .. (I had to click on continue on this site even if it is dangerous to access it)
During the instatllation, I was suggested to install "certutil", is it necessary to solve this problem?
WARNING "certutil" is not available, so the CA can't be automatically installed in Firefox and/or Chrome/Chromium!<br />Install "certutil" with "apt install libnss3-tools" or "yum install nss-tools" and re-run the command<br />Generating a default certificate for HTTPS support
Thank you
Hey ojtouch
Yes, I think you have to install that library in order to generate a "valid" certificate for your localhost
Cheers!
Hello SymfonyCasts,
I use Symfony built-in local web server for dev, and got Symfony 4 Exception: "Error: Maximum execution time of 30 seconds exceeded" because the page took a long time to load data. I know that I have to change the value max_execution_time=30 to greater time allowed in the php.ini file. But how do I find this php.ini for this built in web server (https://localhost:8000/data/).
Thank you for your help!
Dung.
Hey Dung L.
I believe Symfony local web-server uses the php.ini file from your CLI installation. Just locate that file and tweak it so we can be sure :)
Also, I recommend you to read this documentation in case you want to change PHP config only to a specific project https://symfony.com/doc/cur...
Cheers!
MolloKhan thank you! that is it! made the change in php.ini - it works, as well thanks for the bonus url above, it will come handy as I dive deeper into fun Symfony! :)
Hey Moh H. ,
What's the deal? I only see "Hhhm" in your comment :)
Cheers!
Hi, when I go to https://localhost:8000 it says the secure connection failed, SSL_ERROR_RX_RECORD_TOO_LONG
I have Windows 7 and Firefox
Any ideas?
Hey Cavisv,
Well, first of all, you can try to load the page without SSL, i.e. use HTTP instead HTTPS for the protocol. Does the http://localhost:8000 works for you?
In this course we suggest to use "symfony serve" command instead of the old "bin/console server:run" one. Do you use "symfony serve"? What version of "symfony" CLI do you have? You can check with "symfony -v". Probably updating to the latest version may fix the problem. Also, could you try the same https://localhost:8000 URL in Google Chrome instead of Firefox? Does it work there?
Cheers!
After doing a Symfony update it works!
Only there remains an error SEC_ERROR_UNKNOWN_ISSUER
But I can click through that.
Thanks
Hey Cavisv,
Great, glad it helps! Unfortunately, I don't use Windows, can't help more with this error. If you still have this issue - feel free to report it to Symfony, I think they can help with it.
Cheers!
Thanks for the quick reply!
Yes, I was already using http, that works fine.
I use "symfony serve"
symfony -v gives "Symfony CLI version v4.5.2 (c) 2017-2019 Symfony SAS"
I already tried Chrome, that gives ERR_SSL_PROTOCOL_ERROR
Hello guys, I was wondering if it is possible to set the IP to 0.0.0.0? I see I can set the --port=80. It's handy so that phones/devices on my network can easily connect.
Hey Skylar
Yes, you totally can. Just run bin/console server:start 0.0.0.0:80
Cheers!
Thank you for the reply. But I wanted to user Symfony Serve to get https. AFAIK, the console server only does http.
Hey Scottie,
Yes, Symfony server via bin/console supports only HTTP, you need to use "symfony serve" for HTTPS support. And you can specify a port explicitly like:
$ symfony serve --port=80
You can try it, but probably you would need to run this command with sudo to grant access for this, though it depends on your OS.
P.S. to know more about any command - run the command with --help at the end, like:
$ symfony serve --help
What about the IP - not sure if it's possible, at least I don't see it in the help output.
Cheers!
Thank you for your, Victor. I was hoping for a secret command line argument like sudo /home/sgutman/.symfony/bin/symfony serve --port=80 --host:0.0.0.0
. Unforturnately, that did not work. Maybe in the future. Again, thanks.
Hello Ryan, i have an error during setup. i cant migrate and also tried schema update too and same error
`
An exception occurred while executing 'CREATE TABLE tag (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, slug VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_389B783989D9B62 (slug), PRIMARY KEY(id
)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB':
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
`
Hey msthzn
That's a problem between your DB version and the DB charset. You have 2 options
1) Update to MySQL 5.6 or higher
2) Set the field's length to 181 (or is it 191? I don't remember, but you can play with that number)
Cheers!
HI. When running symfony serve I get
[InvalidArgumentException]
Command "serve" is not defined.
Am I missing something?
Cheers
Steve
Never-mind. I needed to download and install the "read the instructions in full" command...
Hey Steve,
Haha, glad you found the solution ;)
Cheers!
Hey Guys,
I downloaded and installed the symfony cli on my Windows machine. When I try to use the new symfony server to browse my application, which is built with webpack encore, my stylesheet (and presumably my .js assets) is not loaded. (It still works with php bin/console server:run.)
Is there a configuration step I'm missing to use the symfony server with webpack encore assets?
Thanks!
Yo Dan_M!
Hmm... interesting! Well, let's do some digging :). Ultimately, your Webpack Encore assets are just normal, boring, physical files inside your public/ directory after they're built - so nothing "weird" should be happening. I'd try this:
1) Restart the new symfony server and browser to your app
2) View source (or inspect element), copy one of the paths to your assets - css or JS - and surf to it - so it'll be something like https://localhost/build/app.css
. Do you see the contents or some error?
The first difference that comes to mind with the two setups is that the symfony server gives you https, instead of http. I can't think why that would effect things - but it possibly may. Also, do you see any errors in your browser's console?
Cheers!
Hey Ryan,
My template has:
{% block stylesheets %}
<link rel="stylesheet" href="{{ asset('build/app.css') }}" />
{% endblock %}
When I view source, I see`
<link rel="stylesheet" href="/build/app.73e7f49c.css" />`
When I click on the link, the stylesheet is downloaded as an attachment, and I see the following in my console:
Resource interpreted as Stylesheet but transferred with MIME type application/x-css: "https://localhost:8000/build/app.73e7f49c.css".```
I don't get it!
Dan
Hey Dan,
Hm, what browser do you use? Could you try in a different browser? Or in incognito mode for example? And what HTML doctype do you have in your base layout, is it:
<!doctype html>
<html>...</html>
Try to explicitly specify type of the loaded file as:
<link rel="stylesheet" type="text/css" href="{{ asset('build/app.css') }}">
Does it help?
Cheers!
Victor,
The doctype is just as you showed. I added the explicit type definition, and that did not change anything.
I use Chrome normally, but I tested in Edge and got the same result.
When I run encore dev-server
, the stylesheet link resolves as:
<link rel="stylesheet" type="text/css" href="http://localhost:8080/build/app.css" />```
The stylesheet loads and everything works perfectly.
When I run `encore production`, the stylesheet link resolves as:
<link rel="stylesheet" type="text/css" href="/build/app.73e7f49c.css" />`
and the stylesheet won't load and throws the warning I showed earlier.
To leave no stone unturned, I changed my template so it would render as`
href="localhost:8080/build...`
but that did not make a difference.
I hope you can see a problem that I can't. Thanks!
"Houston: no signs of life"
Start the conversation!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.1.3",
"ext-iconv": "*",
"aws/aws-sdk-php": "^3.87", // 3.87.10
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/annotations": "^1.0", // 1.10.1
"doctrine/doctrine-bundle": "^1.6.10", // 1.10.2
"doctrine/doctrine-migrations-bundle": "^1.3|^2.0", // v2.0.0
"doctrine/orm": "^2.5.11", // v2.7.2
"knplabs/knp-markdown-bundle": "^1.7", // 1.7.1
"knplabs/knp-paginator-bundle": "^2.7", // v2.8.0
"knplabs/knp-time-bundle": "^1.8", // 1.9.0
"league/flysystem-aws-s3-v3": "^1.0", // 1.0.22
"league/flysystem-cached-adapter": "^1.0", // 1.0.9
"liip/imagine-bundle": "^2.1", // 2.1.0
"nexylan/slack-bundle": "^2.0,<2.2.0", // v2.1.0
"oneup/flysystem-bundle": "^3.0", // 3.0.3
"php-http/guzzle6-adapter": "^1.1", // v1.1.1
"phpdocumentor/reflection-docblock": "^3.0|^4.0", // 4.3.0
"sensio/framework-extra-bundle": "^5.1", // v5.2.4
"stof/doctrine-extensions-bundle": "^1.3", // v1.3.0
"symfony/asset": "^4.0", // v4.2.3
"symfony/console": "^4.0", // v4.2.3
"symfony/flex": "^1.9", // v1.21.6
"symfony/form": "^4.0", // v4.2.3
"symfony/framework-bundle": "^4.0", // v4.2.3
"symfony/property-access": "4.2.*", // v4.2.3
"symfony/property-info": "4.2.*", // v4.2.3
"symfony/security-bundle": "^4.0", // v4.2.3
"symfony/serializer": "4.2.*", // v4.2.3
"symfony/twig-bundle": "^4.0", // v4.2.3
"symfony/validator": "^4.0", // v4.2.3
"symfony/web-server-bundle": "^4.0", // v4.2.3
"symfony/yaml": "^4.0", // v4.2.3
"twig/extensions": "^1.5" // v1.5.4
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.0", // 3.1.0
"easycorp/easy-log-handler": "^1.0.2", // v1.0.7
"fzaninotto/faker": "^1.7", // v1.8.0
"symfony/debug-bundle": "^3.3|^4.0", // v4.2.3
"symfony/dotenv": "^4.0", // v4.2.3
"symfony/maker-bundle": "^1.0", // v1.11.3
"symfony/monolog-bundle": "^3.0", // v3.3.1
"symfony/phpunit-bridge": "^3.3|^4.0", // v4.2.3
"symfony/stopwatch": "4.2.*", // v4.2.3
"symfony/var-dumper": "^3.3|^4.0", // v4.2.3
"symfony/web-profiler-bundle": "4.2.*" // v4.2.3
}
}
Hello,
I'm having some issues installing the server.
As expected I have the [InvalidArgumentException] Command "serve" is not defined. so I tried to run the installation command but I'm getting a [InvalidArgumentException] There are no commands defined in the "server:ca" namespace. . I also tried to reinstall symfony but I still get the same results.
Did anyone have this issue?? (Mac OS btw)