Hi, when I run app in the browser, I have this kind of error: "FatalErrorException in classes.php line 6706: Compile Error: strict_types declaration must be the very first statement in the script" This file "classes.php" is from "./app/cache/dev/" directory. I don't know what to do with this. I tried to put "declare(strict_types=1);" in first line of this file but it doesn't help. I'm using php 7.1 for this app. Maybe someone had this kind of problem and could help me. Jakub
There is also an issue with "hautelook/alice-bundle". I had an error like this during executing "composer install": "remote: repository not found fatal: repository 'https://github.com/hautelook/AliceBundle.git/' not found" Probably something happened with this repository. I fixed this by adding this to composer.json:
Nice catch! I wonder what command exactly failed for you? That should work even without that VCS URL, so maybe we have a blind spot in this tutorial. Would appreciate if you share your steps to reproduce for that error.
Hi Victor, As I wrote, composer couldn't install "hautelook/alice-bundle". This alice-bundle probably contains tools for the fixtures (sorry that maybe I'm not very precise but I'm still a begginer). That is why I added some lines to composer.json (see in my previous post) and run 'composer update'. Then, when I thought that everything is OK, I run commands to create database and fixtures and it was still working. Then, I run server, opened app in browser and got this error in 'classes.php' (see my first post). I hope that it would help you to improve this tutrial code and maybe you could help me to run it at last. I will try to switch from php 7.1 to 7.2 and I hope it will help me. Best regards, Jakub
Aha, I see now. I updated the lock file in the project code to update the link to a new repository, it should work out of the box now when you download the source code. Thanks for reporting and sharing more info about it!
Hi again Victor, I managed to workaroud the problem with "declare(strict_types=1)", but the solution I applied isn't perfect (in fact I think it is far away form perfection). My soluction is like this:
After I managed to install app via composer I run server and then open app in browser. This causes additional files to appear in the "app/cache" directory along with the troublesome "classes.php" file. Of course at this stage the issue with strict_types appears.
Using PhpStorm I change every single php file in app to have "declare(strict_types=1);" at the beginning (don't worry, I use automatic function in phpstorm). But 'classes.php' file has also this code in 6721 line (it also causes error) so I delete it.
Now, the app works fine until I clear cache (sometimes it needs to be done but I hope that not very often during this course).
If someone would have same issues with this course I hope it will help. Cheers, Jakub
Thanks for sharing this tip with others. Yeah, changing cache files is not a robust solution, unfortunately. Hm, what PHP version do you have locally? Also, what OS do you use? I suppose you're on a Windows. That might cause some issues sometimes.. Probably updating dependencies might fix this problem if the problem only in the compiled files. Also, see this StackOverflow post about the error you mentioned, it might be related: https://stackoverflow.com/questions/53376444/getting-fatal-error-while-i-am-trying-to-use-the-declarestrict-types-1-on-my
Hi victor, my OS is Linux Ubuntu 22.04 LTS. For this app I use PHP 7.2 but I also use ppa:ondrej/php package to switch between different versions of PHP. Anyway, thank you for this stackoverflow link. I'm going to check if it would fit for me.
Hello, I am going crazy. I have php 7.2.33 installed.
When I triyed to composer install I get this error In Process.php line 143:
[TypeError] Argument 1 passed to Symfony\Component\Process\Process::__construct() must be of the type array, string given, called in C:\go pro doctrine\vendor\sensio\distribution-bundle\Sensio\Bundle\DistributionBundle\Composer\ScriptHandler.php on line 455
Sorry for the late response, it seems that there is some incompatibility in Sensio bundle and your composer version. Can you try to downgrade composer to version 1 with composer self-update --1 and try installation process again.
Hi Ryan, I'm very beginner in Symfony! I have 2 questions here:
1-My PHP version is 7.3.24 and this project support PHP version("php": ">=5.3.3, <7.3.0")! Do I need to downgrade my PHP version or modify composer.json PHP version?
2-I have opened the start project inside The"Go Pro with Doctrine Queries" but below setup is quite unclear to me! Would you please explain to me what should I do?
Project Setup: Configure parameters.yml: Copy app/config/parameters.yml.dist to app/config/parameters.yml and configure any of the database_ options.
oh, I see my questions have been already answered below! So if I understand it correctly, this is quite old project and needs to be upgraded but still good to watch.
Good catch! I'm glad you found the answers below by yourself :) If you still have any questions following this course - please, let us know in the comments and we will help you.
> So if I understand it correctly, this is quite old project and needs to be upgraded but still good to watch.
Yes, you're right! There're 2 ways: 1) Downgrade your PHP version to 7.2 for example so that you could follow this course. You can keep the current PHP version you have and try to install an alternative legacy version instead that you will use to follow this tutorial
2) Download the course code, go to start/ directory, and upgrade the dependencies with "composer update" command so that it would support a higher version of PHP, e.g. 7.3 you have installed. But it may require some extra work and if you're a "very beginner" - it might be a bit tricky for you.
So, I'd suggest you to go with the 1st option. Meanwhile, we're going to release an upgraded tutorial for this topic in the future, but unfortunately I don't have any estimations yet when it might be released.
Hi, i was wondering if you had an update on your previous reply to Jay. I would love to do this course, but I'm not able to because of the outdated code. Any estimate when an updated course is available? Learning Symfony is not complete without Doctrine Queries
Yes! We *have* finished sorting out the dependency issues and each tutorial now advertises (when you hover over the download) which versions of PHP it supports. Unfortunately, this tutorial requires PHP 7.2 or lower - we would have to upgrade the dependencies way too much (and potentially causing the code ti start behaving differently than the video) to get support for higher versions.
So, for now, I don't have a great answer - I apologize :/. The content in the video still works - this part of Doctrine has not changed. But, if you want to download the course code and code along, you'll have to do that using PHP 7.2 or lower. I'll talk with the team: we may do an update on this tutorial to extend its life. I agree with you: it's a critical topic.
I cannot get this project started. The starting code gives me an error on composer install
On composer update is the same error.
Here is the stack trace.
[Symfony\Component\Debug\Exception\ContextErrorException] Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
[RuntimeException] An error occurred when executing the "'cache:clear --no-warmup'" command:
Deprecated: Array and string offset access syntax with curly braces is deprecated in /Users/Jay/Documents/symfony/doctrinepro/start/vendor/symfony/symfony/src/Symfony/Component/Yaml/Unescaper.php on line 70
Cannot load Zend OPcache - it was already loaded PHP Deprecated: Array and string offset access syntax with curly braces is deprecated in /Users/Jay/Documents/symfony/doctrinepro/start/vendor/symfony/symfony/src/Symfony/Component/Yaml/Unescaper.ph p on line 70
[Symfony\Component\Debug\Exception\ContextErrorException] Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
Bah, sorry about that! You're totally right - the problem happens with PHP 7.3 and 7.4. Basically, when those versions of PHP came out, there we some slight changes that caused breakages in some of our dependencies. This caught us a bit by surprise, and we're still putting systems into place to catch this and fix existing tutorials. We've also updated the dependencies for many tutorials to bring in newer versions that work with PHP 7.3 and 7.4.
In this case, this tutorial is (unfortunately) quite old - so old that we can't update its dependencies without making *major* changes :/. The reason the tutorial is old is that the Doctrine query logic hasn't changed in awhile - so there wasn't a good reason to update. But, this has forced our hand. Unfortunately, for the few tutorials that are in this situation, we're still catching up with wither (A) re-recording them or (B) at least communicating the PHP incompatibilities.
That's a LONG way of saying (A) you're right and (B) it's our fault. We're working to make this *not* a problem (and very transparent where it is a problem), but that's ongoing. My apologies! For this tutorial, the only solution currently is to use PHP 7.2 or lower, unfortunately. Or you can "steal" the code and put it into a newer project - I'd be happy to help if you have any issues.
There are two ways you can see your queries being executed: 1) Activate MySql logging. It will slow down your application but for dev purposes it should be good enough - https://stackoverflow.com/a/304008 2) Run your commands passing in -vvv flag.
UPD: Or you know what, just try to run "composer update" first. Actually, I had the similar error for this course and "composer update" helped me. I also pushed changes, so when you download this course again it will contain updated dependencies and this error should be gone.
Aha, I tested it on PHP 7.2. So, the problem in PHP 7.3. Actually, if you google this error message - you will see some search results for PHP 7.3. So, there're a few possible solutions: - You can downgrade your PHP version to 7.2 - Or try to debug further and find the problem in code. If it's a custom code - you can easily fix the problem, but if it's a code in vendor/ directory - you can try to upgrade related dependency to the latest version. But sometimes in order to do so - you need to upgrade more related dependencies that's not an easy task and may require some changes in the code. It looks related to Doctrine, see these issues: - https://github.com/symfony/... - https://github.com/doctrine...
So I can recommend you to try to upgrade Doctrine ORM first to the latest available version, it should fix the problem.
This tutorial is kinda old already, so it may not work on the latest version of PHP, because 7.3 was released less than month ago.
thank you for the help men bij downgrading to php 7.2 it works now i don't get the error anymore. But i still want to try to make it work on php 7.3 but for now i will keep it at php 7.2.
Glad it works! Yeah, totally agree, downgrading PHP versions is a bummer! So, when you're ready - try to upgrade dependencies to the latest versions, we lock minor/major versions in composer.json so you can upgrade easily without BC breaks. But you can manually tweak those minor/major version constraints to allow upgrading to the latest available version, but you probably also will need to do some changes in the project.
Or you can create a totally new project on the latest Symfony and try to follow this tutorial on it. Well, you would probably need to add some code, but most of it is just a copy/paste from the downloaded code I think.
Hi guys! I have a problem with the course code and its installation. Fatal error: require_once(): Failed opening required 'C:\OpenServer\domains\startdoc\app/bootstrap.php.cache' (include_path='.;c:/openserver/modules/php/PHP-7.0-x64;c:/openserver/modules/php/PHP-7.0-x64/PEAR/pear') in C:\OpenServer\domains\startdoc\app\console on line 10
Hello After configuring paramaters.yml and installing composer, I am unable to start the server or create the database. The error message is:
[Symfony\Component\Debug\Exception\ContextErrorException] Warning: A non-numeric value encountered
I should note: Before this course I was going through the Symfony 3 path and I believe this course is in Symfony2. So I suspect that may be part of the problem. Any help getting passed this issue would be greatly appreciated.
You are correct, this project runs on Symfony 2.6. I believe that error you are getting is related to an incompatibility between Symfony2 and PHP7. You are on PHP7, right? Hmm, try updating your dependencies "$ composer update"
Hi guys! I have a problem with the course code and its installation through terminal in ubuntu! I follow the instructions of readme file and i got these errors when i tried to run "php composer.phar update ":
1) [Doctrine\Common\Annotations\AnnotationException] You have to enable opcache.load_comments=1 or zend_optimizerplus.load_comments=1. 2) Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception 3) [RuntimeException] An error occurred when executing the "'cache:clear --no-warmup'" command.
Now i have the following errors: 1) Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception (didn t change from the previous time) 2) [RuntimeException] An error occurred when executing the "'cache:clear --no-warmup'" command: PHP Fatal error: Class 'Symfony\Component\HttpKernel\Kernel' not found in /home/projects_linux/queries1/app/AppKernel.php on line 6 (these is like the previous but with the AppKernel problem that i have it when i try to use database:create)
Do you know how can i fix it? Thanks in advanced!!
For point 1): You have to locate your "php.ini" file, run in a terminal "$ php -i", then open it and activate your opcache or zend_optimize (it depends which one you are using), if you are using opcache, you just have to add this two lines to your file:
Thanks for your immediate reply Diego! Unfortunately, this didn t help me, but because i m using symfony 3 (i am new in this) i found the solution here... https://stackoverflow.com/q... so instead of running to the terminal the command that you write in readme file of the course "php composer.phar install" because it gives me many exceptions i run the command from the second answer "composer require doctrine/annotations" and i didn t have none problem! p.s. of course i reinstall everything from scratch! But also thank you again for your answer and keep up the wonderful work that you re doing!
namespace AppBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Nelmio\Alice\Fixtures;
class LoadFixture implements FixtureInterface
{
public function load(ObjectManager $manager)
{
Fixtures::load(__DIR__.'/fixtures.yml', $manager);
}
}
Ya..category works. But I have create a category_id field and setter inside my Entity. would that works? Or I better off stick with category object instead?
The coolness here is that you don't need to add "category_id" - you operate objects. Since Category is object and you create this type of objects with Alice - you just may set it below for your FortuneCookie entity and Alice make everything for you, i.e. set the whole Category object with FortuneCookie::setCategory(). Of course, you need FortuneCookie::setCategory() setter to make it possible.
Hello Please, can your tell me we why dump() query looks like: string(105) "SELECT c0_.id AS id0, c0_.name AS name1, c0_.iconKey AS iconKey2 FROM category c0_ ORDER BY c0_.name DESC" what mean "c0_.id AS id0"? what is "c0_"? why it is written this " c0_.name AS name1"?
why dump() query: $dql = 'SELECT cat FROM AppBundle\Entity\Category cat ORDER BY cat.name DESC'; Doesn't look like for example: 'SELECT id, name, iconKey FROM ORDER BY name DESC'; ?
It's something related to SQL knowledges, i.e. in your example "category c0_" means creating an alias "c0_" for "category" table. So now I can refer to this table by its short alias "c0_" where "c" is the first letter of real table name, and "0" just means an index. If you have a joins, you'll see that tables have different indexes and it makes sense, because you may have table names that start with the same latter like "posts", "products", etc. The same for column names like c0_.name AS name1 where name1 is the field alias. So with these aliases Doctrine reduces the query length - probably not too much important, but I suppose in this way it's easier to transform query builder into raw SQL queries. Actually, it comes from Doctrine internals.
So in shorts, Doctrine uses SQL aliases because it's a good practice to use them and because it's easier to automate transformation of query builder into raw SQL queries. And probably you won't need to see those raw SQL queries, maybe just for debugging, but it's really rare case.
Yes, you can use some of them like COUNT(), etc. but most of them are unavailable out of the box. However, with third-party packages you can add support for more native SQL functions, for example, see https://github.com/beberlei... for more information.
Hi Ryan, it seems you are using symfony 2.6 for this tutorial. I just watched all of your symfony 3 tutorials and started coding in symfony3, is there a way to use symfony 3 in this project too? I don't suppose change "symfony/symfony": "2.6.*" in composer.json to "symfony/symfony": "3.1.*" will do the trick?
61 Comments
Hi,
when I run app in the browser, I have this kind of error:
"FatalErrorException in classes.php line 6706:
Compile Error: strict_types declaration must be the very first statement in the script"
This file "classes.php" is from "./app/cache/dev/" directory. I don't know what to do with this. I tried to put "declare(strict_types=1);" in first line of this file but it doesn't help.
I'm using php 7.1 for this app.
Maybe someone had this kind of problem and could help me.
Jakub
There is also an issue with "hautelook/alice-bundle". I had an error like this during executing "composer install":
"remote: repository not found
fatal: repository 'https://github.com/hautelook/AliceBundle.git/' not found"
Probably something happened with this repository. I fixed this by adding this to composer.json:
Hey Jakub,
Nice catch! I wonder what command exactly failed for you? That should work even without that VCS URL, so maybe we have a blind spot in this tutorial. Would appreciate if you share your steps to reproduce for that error.
Cheers!
Hi Victor,
As I wrote, composer couldn't install "hautelook/alice-bundle". This alice-bundle probably contains tools for the fixtures (sorry that maybe I'm not very precise but I'm still a begginer). That is why I added some lines to composer.json (see in my previous post) and run 'composer update'. Then, when I thought that everything is OK, I run commands to create database and fixtures and it was still working. Then, I run server, opened app in browser and got this error in 'classes.php' (see my first post). I hope that it would help you to improve this tutrial code and maybe you could help me to run it at last. I will try to switch from php 7.1 to 7.2 and I hope it will help me.
Best regards,
Jakub
Hey Jakub,
Aha, I see now. I updated the lock file in the project code to update the link to a new repository, it should work out of the box now when you download the source code. Thanks for reporting and sharing more info about it!
Cheers!
Hi again Victor,
I managed to workaroud the problem with "declare(strict_types=1)", but the solution I applied isn't perfect (in fact I think it is far away form perfection). My soluction is like this:
If someone would have same issues with this course I hope it will help.
Cheers,
Jakub
Hey Jakub,
Thanks for sharing this tip with others. Yeah, changing cache files is not a robust solution, unfortunately. Hm, what PHP version do you have locally? Also, what OS do you use? I suppose you're on a Windows. That might cause some issues sometimes.. Probably updating dependencies might fix this problem if the problem only in the compiled files. Also, see this StackOverflow post about the error you mentioned, it might be related: https://stackoverflow.com/questions/53376444/getting-fatal-error-while-i-am-trying-to-use-the-declarestrict-types-1-on-my
Cheers!
Hi victor,
my OS is Linux Ubuntu 22.04 LTS. For this app I use PHP 7.2 but I also use ppa:ondrej/php package to switch between different versions of PHP. Anyway, thank you for this stackoverflow link. I'm going to check if it would fit for me.
Hello,
I am going crazy.
I have php 7.2.33 installed.
When I triyed to composer install I get this error
In Process.php line 143:
Thank you in advance
Hey zahariastefan462
Sorry for the late response, it seems that there is some incompatibility in Sensio bundle and your composer version. Can you try to downgrade composer to version 1 with
composer self-update --1and try installation process again.Cheers!
Thank you for the response, I'll try then tell you
Hi Ryan, I'm very beginner in Symfony! I have 2 questions here:
1-My PHP version is 7.3.24 and this project support PHP version("php": ">=5.3.3, <7.3.0")!
Do I need to downgrade my PHP version or modify composer.json PHP version?
2-I have opened the start project inside The"Go Pro with Doctrine Queries" but below setup is quite unclear to me!
Would you please explain to me what should I do?
Project Setup:
Configure parameters.yml:
Copy app/config/parameters.yml.dist to app/config/parameters.yml and configure any of the database_ options.
Thank you
oh, I see my questions have been already answered below!
So if I understand it correctly, this is quite old project and needs to be upgraded but still good to watch.
Hey Roozbeh,
Good catch! I'm glad you found the answers below by yourself :) If you still have any questions following this course - please, let us know in the comments and we will help you.
> So if I understand it correctly, this is quite old project and needs to be upgraded but still good to watch.
Yes, you're right! There're 2 ways:
1) Downgrade your PHP version to 7.2 for example so that you could follow this course. You can keep the current PHP version you have and try to install an alternative legacy version instead that you will use to follow this tutorial
2) Download the course code, go to start/ directory, and upgrade the dependencies with "composer update" command so that it would support a higher version of PHP, e.g. 7.3 you have installed. But it may require some extra work and if you're a "very beginner" - it might be a bit tricky for you.
So, I'd suggest you to go with the 1st option. Meanwhile, we're going to release an upgraded tutorial for this topic in the future, but unfortunately I don't have any estimations yet when it might be released.
I hope this helps!
Cheers!
Sure Victor,
Thank you
Hi, i was wondering if you had an update on your previous reply to Jay. I would love to do this course, but I'm not able to because of the outdated code. Any estimate when an updated course is available? Learning Symfony is not complete without Doctrine Queries
Hey Paul D.!
Yes! We *have* finished sorting out the dependency issues and each tutorial now advertises (when you hover over the download) which versions of PHP it supports. Unfortunately, this tutorial requires PHP 7.2 or lower - we would have to upgrade the dependencies way too much (and potentially causing the code ti start behaving differently than the video) to get support for higher versions.
So, for now, I don't have a great answer - I apologize :/. The content in the video still works - this part of Doctrine has not changed. But, if you want to download the course code and code along, you'll have to do that using PHP 7.2 or lower. I'll talk with the team: we may do an update on this tutorial to extend its life. I agree with you: it's a critical topic.
Cheers!
thanks for that Jay
Cheers,
Paul
I cannot get this project started. The starting code gives me an error on composer install
On composer update is the same error.
Here is the stack trace.
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
Deprecated: Array and string offset access syntax with curly braces is deprecated in /Users/Jay/Documents/symfony/doctrinepro/start/vendor/symfony/symfony/src/Symfony/Component/Yaml/Unescaper.php on
line 70
Cannot load Zend OPcache - it was already loaded
PHP Deprecated: Array and string offset access syntax with curly braces is deprecated in /Users/Jay/Documents/symfony/doctrinepro/start/vendor/symfony/symfony/src/Symfony/Component/Yaml/Unescaper.ph
p on line 70
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
Hey James M.!
Bah, sorry about that! You're totally right - the problem happens with PHP 7.3 and 7.4. Basically, when those versions of PHP came out, there we some slight changes that caused breakages in some of our dependencies. This caught us a bit by surprise, and we're still putting systems into place to catch this and fix existing tutorials. We've also updated the dependencies for many tutorials to bring in newer versions that work with PHP 7.3 and 7.4.
In this case, this tutorial is (unfortunately) quite old - so old that we can't update its dependencies without making *major* changes :/. The reason the tutorial is old is that the Doctrine query logic hasn't changed in awhile - so there wasn't a good reason to update. But, this has forced our hand. Unfortunately, for the few tutorials that are in this situation, we're still catching up with wither (A) re-recording them or (B) at least communicating the PHP incompatibilities.
That's a LONG way of saying (A) you're right and (B) it's our fault. We're working to make this *not* a problem (and very transparent where it is a problem), but that's ongoing. My apologies! For this tutorial, the only solution currently is to use PHP 7.2 or lower, unfortunately. Or you can "steal" the code and put it into a newer project - I'd be happy to help if you have any issues.
Cheers!
Is there a way to see the full sql with parametres of doctrine query in command(ContainerAwareCommand), something like queries in profiler ?
Hey Helmi
There are two ways you can see your queries being executed:
1) Activate MySql logging. It will slow down your application but for dev purposes it should be good enough - https://stackoverflow.com/a/304008
2) Run your commands passing in
-vvvflag.Cheers!
Hi!
When i run composer install after i setup the parameter.yml I get the following error.
https://imgur.com/a/0pVrqAc
And i don't get why i get this error because i just followed the README
Hey Emin,
Hm, could take a look at this thread? https://symfonycasts.com/sc...
Does it help you to fix this problem?
UPD: Or you know what, just try to run "composer update" first. Actually, I had the similar error for this course and "composer update" helped me. I also pushed changes, so when you download this course again it will contain updated dependencies and this error should be gone.
Cheers!
Hey Victor,
Thank you for the fast reply.
When I redownload the course code i get the same error. And when I i run composer update i get the following error.
https://imgur.com/a/RIbURoj
So i think i made it worse. And i have the same problem with the Ansible course.
Kind regards
Emin
Hey Emin,
Oh, interesting... I did it yesterday and it worked perfect for me. Let's try to figure it out. What PHP version do you have?
Cheers!
Hi Victor,
I have currently php 7.3.
Cheers!
Hey Emin,
Aha, I tested it on PHP 7.2. So, the problem in PHP 7.3. Actually, if you google this error message - you will see some search results for PHP 7.3. So, there're a few possible solutions:
- You can downgrade your PHP version to 7.2
- Or try to debug further and find the problem in code. If it's a custom code - you can easily fix the problem, but if it's a code in vendor/ directory - you can try to upgrade related dependency to the latest version. But sometimes in order to do so - you need to upgrade more related dependencies that's not an easy task and may require some changes in the code. It looks related to Doctrine, see these issues:
- https://github.com/symfony/...
- https://github.com/doctrine...
So I can recommend you to try to upgrade Doctrine ORM first to the latest available version, it should fix the problem.
This tutorial is kinda old already, so it may not work on the latest version of PHP, because 7.3 was released less than month ago.
Cheers!
Hey Victor,
thank you for the help men bij downgrading to php 7.2 it works now i don't get the error anymore. But i still want to try to make it work on php 7.3 but for now i will keep it at php 7.2.
Cheer!
Hey Emin,
Glad it works! Yeah, totally agree, downgrading PHP versions is a bummer! So, when you're ready - try to upgrade dependencies to the latest versions, we lock minor/major versions in composer.json so you can upgrade easily without BC breaks. But you can manually tweak those minor/major version constraints to allow upgrading to the latest available version, but you probably also will need to do some changes in the project.
Or you can create a totally new project on the latest Symfony and try to follow this tutorial on it. Well, you would probably need to add some code, but most of it is just a copy/paste from the downloaded code I think.
Cheers!
Hi guys!
I have a problem with the course code and its installation.
Fatal error: require_once(): Failed opening required 'C:\OpenServer\domains\startdoc\app/bootstrap.php.cache' (include_path='.;c:/openserver/modules/php/PHP-7.0-x64;c:/openserver/modules/php/PHP-7.0-x64/PEAR/pear') in C:\OpenServer\domains\startdoc\app\console on line 10
How can I fix this error?
Hey Nina!
I believe you forgot to run "composer install"
Is there a PHPStorm plugin that helps me with my DQL queries? It looks like it's interpreting it as regular SQL which is not helping very much :)
Hey Johan,
Use the same Symfony plugin for PhpStorm - it should help with it a bit, at least it helps with doctrine query builders.
Cheers!
Ye I noticed :)
It does not help with DQL queries, but indeed it helps with the query builders which I will probably be using most of the time.
Thanks Victor!
Hello
After configuring paramaters.yml and installing composer, I am unable to start the server or create the database. The error message is:
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: A non-numeric value encountered
I should note: Before this course I was going through the Symfony 3 path and I believe this course is in Symfony2. So I suspect that may be part of the problem. Any help getting passed this issue would be greatly appreciated.
Dank
Hey @John
You are correct, this project runs on Symfony 2.6. I believe that error you are getting is related to an incompatibility between Symfony2 and PHP7. You are on PHP7, right?
Hmm, try updating your dependencies "$ composer update"
Cheers!
Hi guys!
I have a problem with the course code and its installation through terminal in ubuntu!
I follow the instructions of readme file and i got these errors when i tried to run "php composer.phar update
":
1) [Doctrine\Common\Annotations\AnnotationException]
You have to enable opcache.load_comments=1 or zend_optimizerplus.load_comments=1.
2) Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
3) [RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
i changed the composer.json as you suggest from this link https://github.com/symfony/...
Now i have the following errors:
1) Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
(didn t change from the previous time)
2) [RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
PHP Fatal error: Class 'Symfony\Component\HttpKernel\Kernel' not found in
/home/projects_linux/queries1/app/AppKernel.php on line 6
(these is like the previous but with the AppKernel problem that i have it when i try to use database:create)
Do you know how can i fix it?
Thanks in advanced!!
Hey argy_13
For point 1): You have to locate your "php.ini" file, run in a terminal "$ php -i", then open it and activate your opcache or zend_optimize (it depends which one you are using), if you are using opcache, you just have to add this two lines to your file:
If for some reason you have more troubles doing it, you can follow this guide: http://www.hostingadvice.com/how-to/enable-php-5-5-opcache-ubuntu-14-04/
I believe this should fix your whole problem, but if not, try updating "distribution-bundle" by running:
$ composer update sensio/distribution-bundle
I hope it fix your problem, have a nice day!
Thanks for your immediate reply Diego!
Unfortunately, this didn t help me, but because i m using symfony 3 (i am new in this) i found the solution here...
https://stackoverflow.com/q...
so instead of running to the terminal the command that you write in readme file of the course
"php composer.phar install" because it gives me many exceptions
i run the command from the second answer
"composer require doctrine/annotations" and i didn t have none problem!
p.s. of course i reinstall everything from scratch!
But also thank you again for your answer and keep up the wonderful work that you re doing!
I'm glad to hear that you could fix your problem, let's keep learning :)
Cheers!
Hi guys:
I try to load fixture to 3.1 since this is 2.6. but I am having troubles
Errors message:
[UnexpectedValueException]
Could not determine how to assign category_id to a AppBundle\Entity\FortuneCookie object
Here is my fixtures.yml
here is my LoadFixture.php
Hey Jian,
Looks like you're trying to assign category to nonexistent property
category_id, usecategoryinstead:Let me know if you still have this error.
Cheers!
Ya..category works. But I have create a category_id field and setter inside my Entity. would that works? Or I better off stick with category object instead?
Hey Jian,
The coolness here is that you don't need to add "category_id" - you operate objects. Since Category is object and you create this type of objects with Alice - you just may set it below for your FortuneCookie entity and Alice make everything for you, i.e. set the whole Category object with FortuneCookie::setCategory(). Of course, you need FortuneCookie::setCategory() setter to make it possible.
Cheers!
Hello
Please, can your tell me we why dump() query looks like:
string(105) "SELECT c0_.id AS id0, c0_.name AS name1, c0_.iconKey AS iconKey2 FROM category c0_ ORDER BY c0_.name DESC"
what mean "c0_.id AS id0"?
what is "c0_"?
why it is written this " c0_.name AS name1"?
why dump() query:
$dql = 'SELECT cat FROM AppBundle\Entity\Category cat ORDER BY cat.name DESC';
Doesn't look like for example:
'SELECT id, name, iconKey FROM ORDER BY name DESC'; ?
Hey Nina,
It's something related to SQL knowledges, i.e. in your example "category c0_" means creating an alias "c0_" for "category" table. So now I can refer to this table by its short alias "c0_" where "c" is the first letter of real table name, and "0" just means an index. If you have a joins, you'll see that tables have different indexes and it makes sense, because you may have table names that start with the same latter like "posts", "products", etc. The same for column names like c0_.name AS name1 where name1 is the field alias. So with these aliases Doctrine reduces the query length - probably not too much important, but I suppose in this way it's easier to transform query builder into raw SQL queries. Actually, it comes from Doctrine internals.
So in shorts, Doctrine uses SQL aliases because it's a good practice to use them and because it's easier to automate transformation of query builder into raw SQL queries. And probably you won't need to see those raw SQL queries, maybe just for debugging, but it's really rare case.
Cheers!
Can I use native sql functions on dql?
Hey William D.
Yes, you can use some of them like COUNT(), etc. but most of them are unavailable out of the box. However, with third-party packages you can add support for more native SQL functions, for example, see https://github.com/beberlei... for more information.
Cheers!
Hi Ryan,
it seems you are using symfony 2.6 for this tutorial. I just watched all of your symfony 3 tutorials and started coding in symfony3, is there a way to use symfony 3 in this project too? I don't suppose change "symfony/symfony": "2.6.*" in composer.json to "symfony/symfony": "3.1.*" will do the trick?
"Houston: no signs of life"
Start the conversation!