I have a site which I've converted to Symfony 6.1 starting from a blank site and copying stuff over from the previous 3.4 site. In dev, everything works perfectly.
Today, I've tried to make it live. I deleted all previous content, cloned my repo and updated to latest version. I created a .env.prod.local file and set the APP_ENV variable to prod from dev.
Symfony is simply not detecting the change of environment. In my folder I have the .env file which is the default, I have not made any changes in that file. In my dev environment, I have .env.dev.local, I changed this to .env.prod.local in my production environment and updated the DB connection string and APP_ENV variable. The resulting errors showed that the env vars were not being picked up. After some research, I ran composer dump-env prod and that produced a .env.local.php file with the same vars as .env.prod.local. However, if I run bin/console debug:container --env-vars it says No environment variables are being used.. If I edit the .env.local.php file and change APP_ENV from 'prod' to 'dev', save and close, and run bin/console debug:container --env-vars again, then I see the vars I am expecting to see.
I cannot run my site in dev mode since it shows the development profiler and this cannot be visible. I cannot run the site in prod since it fails to pickup the vars from the .env.local.php file sometimes - some pages work while others throw a 500 internal server error. On the pages that throw a 500 error, if I change APP_ENV back to dev and load the page again, there is no error and no problems shown in the profiler. I have no information about what the error is in prod mode, I just see a generic error message and there are no logs or error messages on the server that I can find.
I'm running on Apache 2.4 and PHP 8.1.
Any help appreciated!!
After some random and desperate testing, I changed the APP_ENV var to 'live', and this allowed me to see the full error message (instead of a generic 500 internal server error message), and that message showed me that I was missing a /config/services_prod.yaml file. I created this file and cleared the cache, and no more error! Also, setting APP_ENV to live does not show the profiler bar, which was better than setting APP_ENV to dev in an actual production environment and having end users seeing the profiler bar...
All in all a massive PITA, setting this site live should have been an easy process and it's ended up costing me 4 hours just because of having no idea what Symfony is doing with environment variables (despite reading the docs like 5 times). I still don't understand why running bin/console debug:container --env-vars with APP_ENV as prod shows No environment variables are being used., while setting APP_ENV to dev or live and running bin/console debug:container --env-vars shows the expected vars. Seems to be a problem with Symfony?
Related
I have a problem with my project in symfony 5.4 (recently update from 4.4)
I deploy my project on the prod server (on a subdomain) and he don't work in prod environnement, but work in dev.
I already :
_ fix permissions for /var folder
_ set up vhosts (i'm on plesk so i put directives in vhost.conf, in my subdomain)
_ install and update composer
The problem is that there is a lot of missing image (it's ok they are on prod), when i run the project in dev, missing image return a 404 error, but when i turn symfony on prod, missing image return a 500 error, and then the all site is on error 500 untill i clear symfony cache.
I have the previous verison (the 4.4 one), who run in the principal domain, and i dont have this problem.
I deploy the exact same project (the new one in 5.4), in an others test server, and he works in dev and prod (no error 500 on image).
I think it's a server problem, but i passed 4 days on this, i tried a lot of thing, and i'm still stuck :)
First, thank you for trying to help me, i appreciate that.
So.
For removing the error with the image (error 500 instead 404), it appears that the problem was coming from my error templates 'bundles/TwigBundles/error.html.twig', i removed all the code and try just a simple tag, clear the cache and then the missing images trhow a 404 error.
I also reinstall composer require symfony/twig-pack
This helped me : https://stackoverflow.com/a/13741553/20040268
So the site was running fast this time, but as soon i changed page, error 500 again...at least it was fast ^^
So i keep digging, and like #user1915746 said, i started searching with php and the error code i send : mod_fcgid: error reading data from FastCGI server.
I tried a lot of thing for removing this error like :
https://stackoverflow.com/a/12192622/20040268
But still not resolved my problem.
Finally i decided to change the all php ^^ I was in 7.4.30, i pass in php 8.0.20 and...voila...no more error 500...
If you guys have the same thing, and tried all i tried, change php version or if you can't try to see if you don't have missing package (like php-cgi).
Thank you again for your time!
I have properly running xdebug on vagrant on my local pc on Ubuntu. It shows its orange table with error info. My testing page is localhost:8030
In Chrome browser I have Xdebug helper.
The problem is that an annoying warning is displaying in PhpStorm each time I refresh the site:
Debug session was finished without being paused
It may be caused by
path mappings misconfiguration or not synchronized local and remote
projects.
To figure out the problem check path mappings
configuration for 'localhost' server at PHP | Servers or enable Break at
first line in PHP scripts option (from Run menu).
I have checked path mappings configuration for 'localhost' server at "PHP | Servers" and they are OK. My PhpStorm project directory is associated to default Vagrant directory /vagrant/web/.
Enabling Break at first line in PHP scripts option does help but it is kind of an opportunism I think.
How to get rid of these PhpStorm warnings?
For PhpStorm 2021.1.1 +
[Ctrl] + [Alt] + S
Settings : Php -> Debug
Scroll to Advanced settings and expand
Uncheck option Notify if debug session was finished without being paused
It would do this if there are no breakpoints being hit when debugging the script. The "break at first line" probably prevents PhpStorm from issuing you the warning, but otherwise it does exactly the same.
In case you do have breakpoints configured, and PhpStorm doesn't stop on them, then it is likely that you have path mappings configured wrongly.
Using Xdebug's xdebug.remote_log=/tmp/xdebug.log setting/feature to see which breakpoints PhpStorm tries to set, and see whether it does so for the correct paths. They will up as breakpoint_set commands in the log file.
I'm working on an apache server (not in localhost) with symfony 4
I have my WebProfilerBundle bundle enable only in dev environment
My DoctrineBundle is enable everywhere
When I update (php bin/console doctrine:schema:update) I always get a
[CAUTION] This operation should not be executed in a production environment!
Even if my APP_ENV=dev and even if I am can see my WebProfiler.
Someone know why ?
Unless you are just 'dumping' the SQL that would be run, or you are explicitly adding the '--force' parameter, it will always show the warning.
In a Vagrant Homestead environment (in Windows via VMware) I get the bare error 500 with some errors (e.g., forgotten "use") but normal Laravel debug error page with others (e.g., failing to define a route properly or failing to pass a variable to a blade template).
I have tried every solution I've found here and in searching, specifically:
Reset permissions of storage dir (changed inside the VM and in Windows via git bash)
Reset permissions of bootstrap/cache dir (changed inside the VM and in Windows via git bash)
Cleared various cache directories
Checked Laravel log (nothing in it about the failed event at all - which seems very odd)
Checked nginx log (nothing in it about the failed event at all - which seems very odd)
Checked FPM log (nothing in it about the failed event at all)
Tried inserting my own exception code, per some people's posts, it never is executed/shown
Tried inserting old error_reporting(E_ALL); ini_set("display_errors", 1); include("file_with_errors.php"); in a few different places per other posts -- nothing.
Tried resetting the encryption key since someone said that might be an issue (why I don't know) -- nothing
Tried reverting back to a backup of a week ago to undo symphony/etc. upgrades -- nothing
Tried composer update -- nothing
Tried php artisan optimize -- nothing
My APP_DEBUG setting is right (and again working appropriately on many errors just not certain ones, like missing "use")
My project has ground to a halt because I can't debug even basic issues, and I'm out of ideas for what to try.
Any help greatly appreciated. I am stuck until I resolve this.
I have set up SonarQube server on my local system and run sonar runner. it will run good with .html file but when i am trying to run with php file, it failed and showing error like:
java illegal language exception blame sample.php file.
I installed all plugin as below.
git
java
javascript
web
php
c#
but it is not working.
You get this blame error because you are trying to analyze a set of files on which you have uncommitted changes.
To fix this:
Either you make sure that you a running an analysis on source code that has been freshly checked out from your version control system (and not changed since then-
Or you tell SonarQube to not try to get SCM information
You will find this in the "Administration > Configuration > SCM" settings page: it is called "Disable the SCM Sensor"
One more possibility to end up with this error "java illegal language exception blame file-name file" is that your repository could have been shallow cloned with depth=1.
In my case, we configured our jenkins to do a shallow clone with depth = 1 and this error came up. When I changed the depth = 2 and re ran the jenkins job, sonar:sonar worked fine and results are pushed to the sonar server.
Look at the field "Shallow clone depth" in the attached image.
Hope this helps.