Symfony - botched project with cache:clear - symfony

I have a little problem concerning cache:clear following a tutorial that told me if I have an error while running the command, I could delete the dev folder by hand in var/cache/dev
So when running the command to clear the cache, I got this error:
[Symfony\Component\Filesystem\Exception\IOException]
Failed to remove file "/var/www/html/Symfony/var/cache/de~/profiler/26/75/2d7526":
So as the error appeared I decided to delete the dev folder in /var/dev
But then I couldn't go anymore on my browser checking if everything worked fine. This error came up.
RuntimeException in ClassCollectionLoader.php line 309: Failed to write cache file "/var/www/html/Symfony/var/cache/dev/classes.php".
I have no idea as how to make it work again.
My dev and prod cache folders are back in my cache folder as expected, but that doesn't do anything. It won't work anymore.
So I'm a bit desperate.

Have you setup correctly the file permissions for the var folder?
See this link: http://symfony.com/doc/current/setup/file_permissions.html

Related

Cordova ripple.js failed to load resource error

Created a default project without modifications, no build errors, but it failed to run and showed errors when running Ripple-Nexus(Galaxy).
As mentioned in here copying your config.xml into your www directory should resolve the ripple.js not found error.
Anyway it seems that the Ripple Simulator works well, even if you get the error, so in the end I found myself ignoring it.

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

I cannot clear the cache (because the cache is outdated)

Trying to deploy my updated Symfony2 application, I ran into the following problem.
(note that my application uses the new Symfony 3 directory structure. replace bin/console with app/console and var/cache with app/cache if you're using the current directory structure)
I have recently renamed one of my service classes (VariantSlugListener). When deploying the application on the staging server, I got the following error when running bin/console assetic:dump --env=prod:
PHP Fatal error: Class 'MyBundle\Listener\VariantSlugListener' not
found in
/var/www/example.com/staging/var/cache/prod/appProdProjectContainer.php
on line 494
Line 494 of appProdProjectContainer.php contains the following code:
return $this->services['3f288d4f09c9906944ba7e17358f669b942397baf9d79d5ff0737bb756df7023_1'] = new \MyBundle\Listener\VariantSlugListener();
It is no surprise that \MyBundle\Listener\VariantSlugListener can not be found, since it has been renamed to \MyBundle\EventListener\VariantSlugSubscriber with the latest update. The solution would be to simply clear Symfony's cache.
However, when trying to clear the cache (using bin/console cache:clear --env=prod) I get the exact same error as with the assetic:dump command. So I get an error because my Symfony cache is outdated, but I can not clear the cache because of the error.
I can probably get around this by manually deleting the contents of the var/cache directory, but that doesn't feel like the best solution.
Am I missing something?
Probably you are triggering some events that are handled in your VariantSlugListener when doing 'cache:clear'. So your only choice is to just remove contents of the cache directory or to replace the value manually and then run cache:clear to warm up the cache.

InvalidArgumentException: The service definition "security.encoder_factory.responses" does not exist

I have a really strange error in a symfony 2 installation.
Everything worked fine until I suddenly ran into this error. The cache cannot be cleared because of the error, which is also preventing me from checking/updating dependencies with Composer.
InvalidArgumentException: The service definition "security.encoder_factory.responses" does not exist
I tried to manually clear the cache (removing the folder, recreating it and setup permissions again) without succes. The error persists and is the result of every request even when a new cache is build.
Is there anybody with a suggestion as to where to look, or how to solve this problem?
The proposed grep of Pazi (see comments) gave no results, zero.
It seemed to be a magic dependency error. After clearing the vendor/ directory, removing the composer.lock file and installing vendors from scratch (with update) it works again.
Maybe it was a not correctly updated autoloader from composer or not complete deleted vendor after removing from composer.json. Sometime magic happens :)

Resources