Symfony2 trying to write to the previous server it was running on? - symfony

I've been developing a Symfony2 app locally and am now at the stage where I would like to deploy it in it's production environment on a server.
I've uploaded all my files and tried to run:
php app/console cache:clear --env=prod
Which gives the following error:
As you can see, it's trying to write to my C:/ drive for some reason. Doing a regular cache:clear works fine, but I can't swap it to the production environment.
At this point, trying to use the app.php version simply loads a blank page. I can't figure out why my app would be trying to write to a directory on a previous server.
Help?

Try empty the cache folder
rm -rf app/cache/*
After this the cache:clear --env=prod command work properly.

Related

How can I make my git changes visible in production mode (Symfony)?

I make changes local on my mac in dev mode.
After committing the changes I login via ssh to my server.
There I make the command git pull
Now I see my changes on my webpage.
Unfortunately this only works in dev mode.
When I change the mode to production mode in my .env file, then I do not see any updates. What can I do?
You probably need to clear the cache. This can be done with the following command :
php bin/console cache:clear
The following command solved the problem:
rm -rf var/cache/
php bin/console cache:clear --env=prod
to be sure
If you use phpfpm on your server, it can also be required to restart phpfpm service after the cache:clear.
This should not be used in production environemment :
rm -rf var/cache

Symfony 2 production env constant errors

I developed my Symfony 2.8 project locally on dev enviroment.
Than i needed to upload it to a server and run it on production.
I did all the steps:
1. Checked it out with git on the server
2. Ran composer install
3. Cleared cache, doctrine cache, installed the assets
4. Configured my database
Saying this ... I`m still getting problems like:
Internel server errors like
No route found for "GET ..
And for some reason it makes requests from time to time to app_dev.php - my ht access clearly states that directory index is app.php and etc
I get double template rendering - the same view is loaded two times - two menu section ... two content section
I am really frustrated, cause ive tried everything i know. Could someone help me, ill provide additional info if needed.
I need any suggestions, ideas and etc that could help me.
My .htaccess file - http://pastebin.com/4XHetMPV
First, try to remove your cache manually and clean your logs :
rm -rf app/cache/* && rm app/logs/prod.log
Then, try to browse a route of your application.
If you still have an error, open your log using cat app/logs/prod.log and find the last error.
If it's a php error caused by a vendor, remove your /vendor directory and run composer update
If you are not able to fix your problem, add to your question the error log and code of the method called by your route that is not working.
As chalasr said, cleaning prod cache manually works after the app.php setup.
I think a command like :
php app/console cache:clear --env=prod --no-debug
should work too.

How to permanently resolve Symfony2 twig_upper_filter error?

Situation:
Production mode
Change a file
One of the pages on the site returns the following 500 internal error.
Run composer update, and the error goes away.
Change a file and the problem returns.
The code calling the twig_upper_filter is buried deep inside the now embedded in symfony bootstrap templates.
What does composer update do that might fix this? It is repeatable (on one server only).
UndefinedFunctionException: "Attempted to call function
"twig_upper_filter" from the global namespace." at
Symfony 2.6.
Because at the end of composer update it does a cache clear, everytime you change something somewhere you need to clear the cache for the change to be visible in the production enviroment.
This is automatic on the development enviroment.
You need to run this from console:
cd /your/symfony/app
php ./app/console cache:clear --env=prod
Letting the web server build the cache resolved the problem. The command line environment must not be exactly the same as the web server php. On this server it is difficult to actually run command line scripts as the web server user.
Therefore, clearing the cache on the command line with no warmup is the work around:
php ./app/console cache:clear --no-warmup --env=prod

moving a symfony2 project to another PC

I developed a project using symfony2/PHP and now I am willing to shift this project to another machine how can I do the same
I tried following
1)I copied project folder to www folder of another machine
2)I edited app\config\parameters.yml on another system
but is not working its giving different erros
Can any one tell me exact staeps
Moving the source and the database should be enough. It is possible, you may have to clean cache.
php app/console cache:clear
Try clearing cache; open console / terminal and type php app/console cache:clear
Try chmod / chown or if you are on a windows machine, try change the owner, check permissions
Try re-run: php composer.phar update
Check your php-version and extensions. (See: http://symfony.com/doc/current/reference/requirements.html)
Cleaning the cache worked for me.
type php app/console cache:clear

symfony 2, demo not working on remote server

I created fresh symfony 2 app which includes AcmeDemoBundle. It works fine.
I commented out in app_dev.php so that it can be accessed from remote server (openshift cloud). On localhost it works without any problem. I git pushed to openshift, and app_dev.php worked as expected.
Then I moved demo routes to route.yml (for production).
On localhost app.php worked without any problem. So I git pushed to openshift but then app.php threw an error:
failed to open stream Acme/DemoBundle/Resources/views/Welcome/index.html.twig
So, I put back demo routes to routes_dev.yml, git pushed, but openshift error persists.
What might be the problem?
EDIT: The problem is that on my localhost path to twig template is "/var/www/html/jba/php/src/JBA/MainBundle/Resources/views/Default/index.html.twig" but on openshift it still looks to the same directory. But openshift dir layout is different, so it can't find the template. I guess I have to configure openshift to look at right directory. Just don't know how.
Have you cleared the cache for the prod environment?
php app/console cache:clear --env=prod
You might also have a look at the server logs/ the sf2 logs within app/logs/prod.log if this won't help.
I issued the following commands before uploading, but somehow cache seems to be not cleared yet.
php /var/www/html/jba/php/app/console cache:clear --env=prod --no-debug
php /var/www/html/jba/php/app/console cache:clear
Only deleting prod and dev directories under app/cache explicitly helped.
See also
Symfony2: access same route in production as development

Resources