Browser closes after project's cache cleaned [symfony2] - symfony

I have a project in symfony 2.3.
I had to clean it's cache to free some space of my server. But after I didn't the browser doesn't even load the page as before. It goes to the link and after it closes without any response.
I don't know which informations are useful to this problem. I had just ran the command:
sudo php app/console cache:clear
Must I clean the cache for the prod environment too?
Is it dangerous to the project to clean the cache of the project? I always think that may crash the whole thing.
Thank you

You should check the permissions of the cache directory and also move your sessions in a separate folder, because a cache:clear also logout any logged user if you don't handle the sessions directory.
framework:
session:
# Don't forget creating the folder /var/sessions with the right permissions
save_path: %kernel.root_dir%/var/sessions

Related

Symfony3.1 : Unable to load css, js files and images on my application in production

I have deploy my Symfony 3.1 application and uploaded it online, following the symfony 3.1 cookbook steps (basic file transfer and common post-deployment tasks); I have checked all the requirements, install vendors, clear cache, and install all assets, but no images, css configurations nor js files are loading. I can only see the raw content.
any idea of what I can do?
thanks.
I can't write a comment, cause have no reputation so I hope my advices will be like answer.
First solution very simple. Check the permissions of your web directory.
chmod -R 0777 ./web
Check the config file (or post it's code here).
check if your paths are relative, something like:
href="/images/myimage.jpg"
Where images - folder which contains in web directory
And from my opinion try to clear cache once more in both dev and prod.

Silverstripe install admin js errors

For some reason my admin screen just hangs with some javascript errors. I have it installed on xampp on windows 7 ultimate 64bit. What could be causing this? Ill post a screenshot of the errors any help would be nice! p.s. This is my first time installing silverstripe ever so be nice. :)
This sort of things usually occurs when combined asset files cannot be created. Make sure the web server user has write access to the assets/ and assets/_combinedfiles folders, then go to your-site.com/admin/pages?flush=1.
Alternatively, since this is a local install, run in dev mode. There are instructions in the documentation on how to set this.
As indicated by #simon_w, this issue occurs due to the folder permissions:
In your local environment, in addition to the way via yml config, you can just put the following in _config.php inside mysite folder.
Director::set_environment_type("dev");
In dev mode, the installation doesnt need to write to assets/_combinedfiles. However, you had better have write permission for assets folder anyway.
So, just increase permissions for assets and directories under it. Uploaded files are also stored there, if not sufficient permission, you can't upload files from the admin panel. Other functionalists may also be affected.

How should I do to clean up the symfony2 cache

I'm a website administrator,my site were build on symfony2 freamwork.
My site has a lot of users.When I clear the cache,a few users are accessing my website,so I can not quite put clean cache that caused a lot of problems.
How should I do to clean up the cache?
To clear the cache in symfony you need to execute the following command :
php app/console cache:clear --env=prod
the --env=prod tells the console to execute in the production environment. This will remove the previous cache.
Note:
By default Symfony will store session information in its cache directory. Clearing the cache will mean that every user has to re-authenticate.
You can change the path that Symfony uses to store the session files by changing the following line in the app/config/config.yml.
framework:
session:
save_path: %kernel.root_dir%/sessions
The save_path setting will then store session information inapp/sessions.
I had faced this problem multiple times. If your website was accessing by so many user and you clear the cache. i am sure your website was down for couple for minutes until the new cache generated.
So clear cache on production server should not be a regular activity.
There are couple of solution or tricks to overcome from this problem:
find the time when your website has low traffic. May be sometime in the night and then clear the cache.
When you want to clear a cache, setup a replica of a production server then plan to switch the public domain ip to the new replica for the timing so that user cant face the downtime and once you cleared the cache on a actually production server. switch the public domain ip back to the production server.
if you do some changes in the templates i.e.twig and wants to made changes live on the production.Then try to find the templates in the app/cache/prod/twig directory and grep the templates name and you will get the files. Than move the files or delete the files and yours changes will live on the production server.
how to clear the cache
php app/console cache:clear
chmod -R 777 app/cache
chmod -R 777 app/logs

Symfony2 login fails when session.storage.filesystem is set for storage_id

I'm trying to do some functional testing with PHPUnit but it requires that I add session.storage.filesystem for the storage_id option in config.yml.
This causes the login process to fail, for some reason. I get the following error in test.log :
Authentication request failed: Your session has timed-out, or you have disabled cookies.
Afterwards I'm redirected to the login page again. I'm certain that I have cookies enabled and that the application works without setting that option(with native session storage).
Could anyone tell me whether there is any solution for this issue?
Give a try at changing your file permissions for the cache folder. If they're not set properly , this is what will happen:
You develop stuff and test it through your web browser => your apache (or other server) will create the cache and will be the only one to have permissions on it
You start phpunit tests from the command line (different unix user) => the current unix user does not have write access to your cache folder and cannot store the sessions.
Immediate fix to validate that this is the case:
chmod -R 777 app/cache/
phpunit -c app/
If this is actually the case, then go check how to properly set the rights at: http://symfony.com/doc/current/book/installation.html#configuration-and-setup

Symfony2 presents rendering different views in dev and prod environment

I designing an programming a website using Symfony2. I completed some parts and checked the client side in both dev and prod environment. In the first time everything was fine and I saw same result in both environments, But after sum changes in views (I'm using Twig with Three-level Inheritance) such as adding sum other stylesheets in "stylesheets" block, dev environment works fine but in prod environment no stylesheets added and its using old data. I cleared cache and log manually from both path "app/cache/dev" and "app/cache/prod" ... but nothing changed. I removed all stylesheets in block and cleared chache again old data is still there!
Any suggestion?
Apart from clearing the cache, make sure you publish your assets:
app/console assets:install --symlink web
app/console assetic:dump
The problem was about removing cache files. I had been removing cache files via cPanel filemanager. It gave "all files removed successfully" but they didn't. So I found another way to clear cache. I used shell_exec:
shell_exec('rm -r app/cache/prod');

Resources