I didn't touch my project since a week and today I have this error when I want to go on my website
Unrecognized option "resources" under "twig.form"
I don't know why.. This was working very fine before...
Here is my config.yml :
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
globals:
breadcrumb_trail: "#apy_breadcrumb_trail"
form:
resources:
- 'AppBundle:Form:fields.html.twig'
If you have any idea.. :)
If you are on SF3 or higher, check that the yaml definition hasn't changed to specify a form template: the current one (3.0.*) should be like this:
twig:
form_themes:
- 'bootstrap_3_layout.html.twig'
source
Related
I would like to use bootstrap 4 CoreUi template in my symfony project.
I added it to my project with
composer require coreui/coreui
Now coreui is in my vendor directory, I would like to add a path in twig.yaml to simplify its access, according to the doc I modified my twig.yaml file like this :
twig:
# paths: ['%kernel.project_dir%/templates']
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
paths:
- '%kernel.project_dir%/templates'
- '%kernel.project_dir%/vendor/coreui': coreui
I get an ErrorException :
Notice: Undefined index: value
The doc doesn't say much... so I don't know what to do at this point.
Apologies for posting the wrong link in my comments. The error you are getting is a twig "feature". Basicially just need to supply a value for the blank namespace.
twig:
#paths: ['%kernel.project_dir%/templates']
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
paths:
#'%kernel.project_dir%/templates': '' # add : ''
'%kernel.project_dir%/vendor/coreui': coreui
Run bin/console debug:twig and all should be well.
Update: Based on the discussion below with #yceruto as well as this github issue, I changed the answer to simply comment out the default templates line. Turns out it is not needed and there is a pull request to remove it. Always wondered why it was there in the first place.
paths: is getting two parameters as array, here
%kernel.project_dir%/templates and %kernel.project_dir%/vendor/coreui are directories must be exists, if not exists you need to create or just remove if don't need one of.
Mine is like that:
twig:
paths: ['%kernel.project_dir%/templates']
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
there is no real detail in the documentation about the AsseticBundle Config - in config.yml.
assetic:
debug: "%kernel.debug%"
use_controller:
enabled: "%kernel.debug%"
profiler: false
read_from: "%kernel.root_dir%/../web"
write_to: "%assetic.read_from%"
java: /usr/bin/java
node: /usr/bin/node
ruby: /usr/bin/ruby
sass: /usr/bin/sass
# An key-value pair of any number of named elements
variables:
some_name: []
bundles:
# Defaults (all currently registered bundles):
- FrameworkBundle
- SecurityBundle
- TwigBundle
- MonologBundle
- SwiftmailerBundle
- DoctrineBundle
- AsseticBundle
- ...
assets:
# An array of named assets (e.g. some_asset, some_other_asset)
some_asset:
inputs: []
filters: []
options:
# A key-value array of options and values
some_option_name: []
filters:
# An array of named filters (e.g. some_filter, some_other_filter)
some_filter: []
workers:
# see https://github.com/symfony/AsseticBundle/pull/119
# Cache can also be busted via the framework.templating.assets_version
# setting - see the "framework" configuration section
cache_busting:
enabled: false
twig:
functions:
# An array of named functions (e.g. some_function, some_other_function)
some_function: []
I'm specially interested in
read_from: don't understand the path, too
write_to:
because I don't really understand how to use it.
So, I want to use SCSS and Compass and I have an folder in AppBundle/Resources/assets/styles/main.scss
What I have to setup in the config.yml, that assetic know how he find the main.scss as a global setting?
Unless you are trying to update the directory from which Assetic reads/writes (thus being /web by default), you don't need to change anything here. The configuration can be understood from a good part on the Symfony documentation. You'll find what you need in:
read_from: "%kernel.root_dir%/../web"
write_to: "%assetic.read_from%"
These are paths to a directory which is writable/readable, and exposed to the public. In this case, it means it will look for /path/to/app/../web for both readings and writings.
In a general manner, check for php app/console config:dump-reference X to find the default configuration of a given bundle, where X is the bundle config name. In your case, try the later: php app/console config:dump-reference assetic
Now, what you want is to use compass/sass from your view as far as I can see.
In your twig file, put the following:
{% stylesheets 'path/to/main.scss' filter='compass' %}
<link rel="stylesheet" type="text/css" href="{{ asset_url }}">
{% endstylesheets %}
After adding the configuration for compass if it needs to be tweaked, you should be all set.
Is it helping? it not, could you please provide more details?
Seeing various threads on this topic but not finding a working answer. Have a simple Symfony2 app (2.3.5) and trying to dump variables passed into my Twig templates. I have in my app/config/config.yml:
# Twig Configuration
twig:
debug: %kernel.debug%
strict_variables: %kernel.debug%
and in my app/config/config_dev.yml:
services:
twig.extension.debug:
class: Twig_Extensions_Extension_Debug
tags:
- { name: twig.extension }
But using dump() in a twig still renders an empty page. I also increased memory limit in php.ini to 512 ... still nothing
Which part of this am I missing?
Try class: Twig_Extension_Debug instead. :)
In symfony2.3, this extension is automatically enabled when twig.debug is set to true, so you should be able to use the dump function.
Try {% debug var %} as shown in this link:
http://www.craftitonline.com/2011/06/symfony2-debugging-with-twig-extensions/
Because I didn't found the answer on the web, I will share my working solution here:
# app/config.yml
twig:
debug: %kernel.debug%
Then in a Twig template:
{% dump var %}
Tested on Symfony 2.7
I am using assetic to manage my CSS files in the Symfony 2 framework. It works well in production mode.
My problem is that in debug mode, assetic keeps combining my files into one output file. It makes it difficult to track a particular CSS style. Plus the combined file is not always updated.
How can I disable this feature in debug mode ?
Edit: Here is my call to assetic:
{% stylesheets filter='lessphp,cssrewrite'
'#DevoptionBaseBundle/Resources/less/front.less'
'#DevoptionBaseBundle/Resources/less/back.less'
'#DevoptionBaseBundle/Resources/public/css/custom-theme/jquery-ui-1.10.0.custom.css'
'#DevoptionBaseBundle/Resources/public/css/jquery.mCustomScrollbar.css'
output='css/style2.css'
%}
There is a configuration for Assetic
In your config.yml, you should have
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
which means that you have to dump the assets in order tu use them.
And in your config_dev.yml, you should have
assetic:
use_controller: true
which means that the assets are loaded each time. You should check this configuration in your config_dev.yml
I'm wondering if anyone can help me with some AsseticBundle configuration in conjunction with Symfony 2's dev environment.
Each time a page loads in the dev environment Assetic will recompile any assets, in my case I am compiling Sass files using the CompassFilter.
My problem is that when I have a malformed Sass file my page simply loads without any generated stylesheet - instead I want Assetic to show me the Compass/Sass compiler output as if an exception had occurred (i.e. I get the Symfony2 "oops" screen).
Does anyone know if there is a configuration to achieve this?
My current config.yml is:
assetic:
debug: %kernel.debug%
use_controller: false
sass: /var/lib/gems/1.8/bin/sass
filters:
compass:
bin: /var/lib/gems/1.8/bin/compass
apply_to: "\.scss$"
scss: ~
with config_dev.yml overriding only one line to:
assetic:
use_controller: true
No, what you ask for is not supported because the stylesheet is processed when it is requested, not when the HTML is requested. However, you should be able to see the error if you request the referenced stylesheet directly.