Twig does not update changes in symfony - php

I am working with Symfony 2.8 in developer mode and Windows 10. When I update template Twig, always I have to clear cache to update render. I looked permissions for folders cache and logs and I have the necessary permissions.
Any help?

Go to app config file (by defualt will be located in ../app/config/config.yml from your root directory). Scroll to the twig configuration settings (under twig:) and change the cache value (which should be pointing to the cache directory) to false like so:
twig:
cache: false
If you do not see any cache configuration entry, simply add the line above.
Or you can disable the twig cache on web/app_dev.php only for avoid any problem when you're going to push your code in prod environnement.

You should try to execute the command below in terminal, in your symfony project directory.
php bin/console cache:clear
Symfony documentation about that:
https://symfony.com/doc/current/deployment.html

Related

creating bundle in symfony in terminal

i want to create a bundle in my symfony project via
php bin/console generate:bundle
but it errors me in the terminal:
[Symfony\Component\Config\Exception\FileLoaderLoadException] The file
"../../src/AppBundle" does not exist (in:
C:\wamp64\www\exp\app/config) in
C:\wamp64\www\exp\app/config\services.yml (which is being imported
from "C:\wam p64\www\exp\app/config\config.yml").
[Symfony\Component\Config\Exception\FileLocatorFileNotFoundException]
The file "../../src/AppBundle" does not exist (in:
C:\wamp64\www\exp\app/config).
You might have deleted AppBundle from src folder (or test folder) manually which is the major reason for getting this error.
Browse app\config\config.yml , app\AppKernel.php and app\config\routing.yml and remove the referring to AppBundle.
Once done Please clear the cache and re-run the project.

Unable to find file "#SonataUserBundle/Resources/config/routing/admin_resetting.xml"

Today I installed Symfony 2.7.9 for the first time and of course I've installed Sonata Admin (successfully). Now I'm trying to install SonataUserBundle like described here. But all the time I get the same error:
Unable to find file "#SonataUserBundle/Resources/config/routing/admin_resetting.xml" in
#SonataUserBundle/Resources/config/routing/admin_resetting.xml (which is being
imported from "/Users/alex/www/Personal/startup-1/app/config/routing.yml"). Make sure
the "SonataUserBundle" bundle is correctly registered and loaded in the application kernel
class. If the bundle is registered, make sure the bundle path
"#SonataUserBundle/Resources/config/routing/admin_resetting.xml" is not empty.
And YES, of course I checked admin_ressetting.xml and found that folder #SonataUserBundle/Resources/config/routing is empty.
Here my files:
config.yml, routing.yml, security.ylm, AppKernel.php
Also I'll note that:
My database contains 0 tables.
In folder src/Application/Sonata I have the only folder UserBundle
It seems there is a real issue with the 2.2.4 version of SonataUserBundle. Indeed admin_ressetting.xml is missing as you can see there.
FYI, I just posted an issue reporting the bug.
You can get the file from the master branch and create it under vendor/sonata-project/user-bundle/Resources/config/routing to fix it meanwhile.
Update (Apr, 28'16)
In fact, that's not an issue but a documentation misleading (the default documentation is ahead of last release). You need to refer to the v2.2 documentation if you want to use the last release, which is the 2.2.4 for now.
If you really checked #SonataUserBundle/Resources/config/routing which should be located under vendor/ and it's empty I would recommend you to delete vendor-directory, clear composer cache (compser clear-cache) and run composer install again.
As you can see at Github the directory should not be empty and contain more files than admin_resetting.xml.

Generating Bundle in Symfony

Can't find a solution for this on stack.
I'm using ubuntu server,
$php app/console generate:bundle --namespace=WMDN/FirstBundle --format=yml
goes fine until :
Generating the bundle code: OK
Checking that the bundle is autoloaded: FAILED
Confirm automatic update of your Kernel [yes]? yes
Enabling the bundle inside the Kernel: OK
Confirm automatic update of the Routing [yes]? yes
Importing the bundle routing resource: OK
The command was not able to configure everything automatically.
You must do the following changes manually.
- Edit the composer.json file and register the bundle
namespace in the "autoload" section:
I thought it was permissions, and set the whole dir to 775 and made sure owner was good.
I thought it was outdated bug for symfony and deleted whole dir, and got 2.4.4
I'm following a tutorial and their bundle generates just fine and I'd like mine to do it as well.
Why can it not autoload? My Namespace should be good to use. I cannot figure it out.
I have composer installed.
Following this tutorial series : http://www.youtube.com/watch?v=GIcY5YYfZ14 and I'd really like to get my first bundle created so I may continue.
In conclusion, what are the reasons a bundle would fail autoload?
Per to comments, solution was to set the --src parameter correctly.

symfony 1.4 clear cache

I want to add a directory in /cache. i.e. /cache/custom and if I run command:
./symfony clear:cache
All files in custom directory gets deleted. I don't want these files deleted even if I run ./symfony cc. Any solution?
The cache directory has a different purpose. You should not write your custom files to folders like cache, logs, components, vendor because they are overridden while running some commands or while running the application.

Symfony2 disable cache?

Is there a way to disable the caching function in Symfony2? I tried to find the setting in the config* and parameters.ini files and I searched a lot. Ok, I found a few solutions, but nothing for the latest version (Symfony2).
WHY? Because I want to test new templates and functions without clearing the app/cache* all the time.
I'm assuming you're using the Twig engine, (the default templating engine for Symfony2). To disable caching in twig, so that you do not have to keep clearing the cache like so:
rm -rf app/cache/*
Navigate to your app config file (by defualt will be located in ../app/config/config.yml from your root directory). Scroll to the twig configuration settings (under twig:) and change the cache value (which should be pointing to the cache directory) to false like so:
twig:
cache: false
If you do not see any cache configuration entry, simply add the line above.
It may also be helpful to checkout the configuring reference for the Twig bundle: http://symfony.com/doc/2.0/reference/configuration/twig.html
After editing your config_dev.yml file, go to your terminal and run:
app/console cache:clear
Okay, regarding your clarification the solution simply is to use the dev-environment through the front-controller web/app_dev.php. Then sf2 keeps track of your adjustments and you don't have to clear the cache.
This original solution works for me http://symfony.com/doc/current/cookbook/debugging.html
In addition to the accepted answer, I propose to edit your config_dev.yml in a way so it still debugs your twig template. To do so, add this code to your config_dev.yml file:
twig:
cache: false
debug: true
services:
twig.extension.debug:
class: Twig_Extension_Debug
tags:
- { name: 'twig.extension' }
After editing your config_dev.yml file, go to your terminal and run:
app/console cache:clear
By doing so, you will reload your config_dev.yml settings - make your project run with the new configuration.
Hope this helps.
Edit 'config_dev.yml' and 'config.yml' and then put in both
twig:
cache: false

Categories