I am putting my website in production, but I have a problem with the environment.As you can see in the screenshot below, the site remains in "dev" mode
However, I already modify my .env file as follows:
APP_ENV=prod
APP_DEBUG=0
APP_SECRET=secretthings
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
#TRUSTED_HOSTS=localhost,example.com
###< symfony/framework-bundle ###
should I change another file or do something else so that my site is finally operational?
Thank you for your answers
Did you try to clear your cache?
Move to your project and type php bin/console cache:clear. You can also pass the enviroment you want to clear with php bin/console cache:clear --env=prod. Use dev or prod as your parameter.
Edit: If you have a .env.local file - you need to change your enviroment there.
After you update your .env file you should run composer dump-env prod to compile your environment file for production use.
Related
I'm trying to pull a key from .env in my vue3 page. I've read the instructions at https://vitejs.dev/guide/env-and-mode.html and I can get VITE_PUSHER_SCHEME using:
console.log(import.meta.env.VITE_PUSHER_SCHEME);
The same doesn't work for VITE_STRIPE_KEY, which I assume means that my .env is cached somehow, so that my changes aren't being reflected. I've tried php artisan config:clear and php artisan cache:clear to ensure it's not cached, but I still get undefined for import.meta.env.VITE_STRIPE_KEY.
My .env includes:
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
VITE_STRIPE_KEY=stripe_key
My vue file has:
console.log(import.meta.env.VITE_STRIPE_KEY);
console.log(import.meta.env.VITE_PUSHER_SCHEME);
How can I refresh my .env file properly so that it's accessible in vue?
Finally, quitting npm and running npm run watch again fixed the problem.
I tried to resolve my problem all this morning but I didn't find the solution anywhere.
I have a Symfony project and I use Assetic for my css and js files.
Till today when I ran php bin/console assetic:dump --env=prod, it worked fine.
But now I have this error :
[Symfony\Component\Config\Exception\FileLocatorFileNotFoundException]
The file "C:\wamp\www\PLIE08\app/config/config_=prod.yml" does not exist.
I don't understand why it adds = in my file.
Moreover, after running this command I realized that a folder called "=prod" is created in var/cache in addition to the dev and prod folder.
I tried to update, install composer, clear the cache, look in config file if something was wrong but I'm still blocked...
Somebody can tell me why it searchs the bad file ?
Thanks
try this command bin/console assetic:dump -e prod to verify duplicated =. Otherwise remove the entire content of the cache/prod folder, doest not clear:cache, remove all manually.
I am trying to set up my symfony 2.8 app for local development.(Following - https://symfony.com/doc/current/deployment/heroku.html)
Added In proc file
web: bin/heroku-php-apache2 web/
Error
bin/sh: vendor/bin/heroku-php-apache2: No such file or directory
Also note , composer.phar config bin-dir is bin
Anyone who can share how they resolved this problem?
First of all, have you tried letting heroku create the Procfile itself? I think lately it was smart enough to work out the root of the Symfony project.
If that doesn't work, maybe that's not the right path, try:
echo 'web: $(composer config bin-dir)/heroku-php-apache2 web/' > Procfile
If none of those work, I'd rather use the heroku information on how to deploy your Symfony app, have a look at this and see if it helps:
https://devcenter.heroku.com/articles/getting-started-with-symfony
I have the issue that my assets, e.g. my sass and javascript, did not recompile on file modification. I installed I accessed them via symlink option and access the dev environment via localhost:8000. I have to manually call /app/console assetic:dump for them to update.
How do I get assetic to watch for file modification?
You can also use
php app/console assetic:dump --watch
If you want to watch for file modifications. This will re-run assetic:dump in the background automatically for you.
And yes dont forget if you use dev then access your site via app_dev.php
And small note... when you use production environment then make sure you execute assetic:dump with --env=prod (without --watch as well)
I realized I have to access the dev page with app_dev.php:
localhost:8000/app_dev.php/
Try to execute:
php app/console assetic:dump --env=dev
My Symfony installation seems to have gotten confused somewhere (probably during a failed cache clear). It seems to think that the production cache folder should be called pro_ instead of prod.
First, when I tried to run $ php console cache:clear --env=prod I got the error message:
[Symfony\Component\Filesystem\Exception\IOException]
Cannot rename "...cache/pro_" to "...cache/pro_".
I'm running on a windows dev machine (so there are no file system permissions issues).
So, I tried deleting all of the cache/* files/folders manually and trying again. This time the cache:clear went through and produced a single prod folder. That folder has subfolders for annotations, assetic, doctrine, sessions and twig.
But when I open the prod front controller (e.g. http://devsite/ in a browser) it fails with the message:
Fatal error: require() [function.require]:
Failed opening required '...cache/pro_/doctrine/orm/Proxies\__CG__AcmeDemoBundleEntityFoo.php'
(include_path='blah, blah, blah')
in ...\vendor\doctrine\common\lib\Doctrine\Common\Proxy\AbstractProxyFactory.php on line 165
From the looks of this it's trying to access cache files in pro_ instead of prod (again).
Looking in the cache folder I can see that __CG__AcmeDemoBundleEntityFoo.php exists under cache\prod but there is now a pro_ folder with annotations and sessions sub-folders.
What's going on and how do I make Symfony forget about pro_ so it can go back to using prod for everything?
I thought everything to do with the cache was stored under the cache folder... is there something else (somewhere) that's storing some reference to pro_? Or am I looking in the wrong place for the solution to this problem?
Edit: Done some more searching and appProdProjectContainer.php contains 16 references to .../cache/pro_. If I manually search and replace these to .../cache/prod the site works. But the next time I run console cache:clear it resets them back to pro_. Where could this errant behaviour be coming from?
Edit2: OK, I got to the bottom of this and have submitted a PR to the Symfony core to try and fix it. The problem was caused by our cache path containing '\' characters which were then escaped in the cache files and failing to match a search/replace command which was meant to clean them up.
app/console cache:clear --env=prod --no-warmup
composer dump-autoload -o
app/console cache:warmup --env=prod
This was a bug in Symfony's handling of cache paths with back-slashes in them.
The short term workaround is to replace them with forward slashes.
Longer term there is a fix posted as https://github.com/symfony/symfony/pull/9184 which will be brought into the core code soon.