I'm working on a Symfony 3.4 application. Assetic bundle wasn't installed, so I made :
$ composer require symfony/assetic-bundle
and add it in the appKernel.php :
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
It worked perfect. Then, in my app/config/config.yml, I added :
# app/config/config.yml
assetic:
debug: '%kernel.debug%'
use_controller: '%kernel.debug%'
filters:
cssrewrite: ~
# ...
and now my front-end is no more available, this is the error displayed with app_dev.php :
ParameterNotFoundException You have requested a non-existent parameter
"templating.engines".
Even if I remove the Assetic configuration out of the config.yml the error is here. I have been searching in all my *.yml files I do not find any property "templating.engines" .... any idea ?
Try adding the following in the config.yml
framework:
...
templating:
engines: ['twig']
Related
I tried to install symfony 4.4 instead. after the installation, I tried to install sonata user bundle and got this error:
The child node "db_driver" at path "fos_user" must be configured.
then I followed this link
https://stackoverflow.com/a/49034641 to create fos_user.yaml
and I got this error:
The service "fos_user.mailer.default" has a dependency on a non-existent service "templating".
then I followed this link
FriendsOfSymfony/FOSUserBundle#2679 (comment)
and I got this error:
The service "sonata.user.admin.user" has a dependency on a non-existent service "sonata.admin.manager.orm".
and I followed this link:
#1050 (comment)
and I got this error:
There is no extension able to load the configuration for "fos_user" (in "/fsys1/home/public_html/mycel7/config/packages/fos_user.yaml"). Looked for namespace "fos_user", found ""framework", "sensio_framework_extra","twig", "web_profiler", "monolog", "debug", "maker", "doctrine", "doctrine_migrations", "security", "twig_extra", "knp_menu", "sonata_doctrine", "sonata_twig", "sonata_form", "sonata_block", "sonata_exporter", "sonata_admin","sonata_doctrine_orm_admin"" in /fsys1/home/public_html/mycel7/config/packages/fos_user.yaml (which is loaded in resource "/fsys1/home/public_html/mycel7/config/packages/fos_user.yaml").
at this step I am not sure what to do then.
This is my config/packages/fos_user.yaml :
fos_user: db_driver: orm firewall_name: main user_class: Entity\User from_email: address: "test#gmail.com" sender_name: "test"
This is my config/packages/framework.yaml:
framework: secret: '%env(APP_SECRET)%' session: handler_id: null cookie_secure: auto cookie_samesite: lax #esi: true #fragments: true php_errors: log: true templating: engines: twig
symfony version is 4.4.
other files are un-touched
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?
I'm using Symfony version 2.3.1 and SmartyBundle version 1.2.0.
I followed the steps 2.3 and 2.4 at https://smartybundle.readthedocs.org/en/latest/installation.html.
But as soon as I enable SmartyBundle in AppKernel.php, I have this error in app/console:
You have requested a non-existent parameter "assetic.use_controller".
Here is an excerpt of my config.yml:
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ ]
I had this same problem.
You need to make sure that the SmartyBundle appears after AsseticBundle in AppKernel registerBundles
I'm having trouble with setting up my Symfony2 production environment. The dev environment through app_dev.php works fine, but production through app.php leades to a 500 Internal Server Error, and this message in the Symfony error log:
[2011-08-28 10:09:11] request.CRITICAL: Symfony\Component\Config\Exception\FileLoaderLoadException: Cannot load resource ".". (uncaught exception) at /var/www/Symfony/vendor/symfony/src/Symfony/Component/Config/Loader/Loader.php line 75 [] []
Don't know how to solve this, or even stack trace it...
Happened to me when I updated the Liip/ImagineBundle.
In older versions of this bundle it required this in your routing:
_imagine:
resource: .
type: imagine
In the new versions this is to be replaced by:
_liip_imagine:
resource: "#LiipImagineBundle/Resources/config/routing.yaml"
So in my case the problem was I updated the bundle via composer, but did not update the routing.yml.
I had the same problem. Try to add:
assetic:
use_controller: true
in /app/config/config_prod.yml and clean cache after that (rm -fr /app/cache/*)
if you have these problems in production environment and you use assetic, then check if you don't have this:
_assetic:
resource: .
type: assetic
in your config file (normally this is in config_dev.yml only, not in production)... in other case try to check other routes with resource: .
I had faced a similar issue while hosting symfony2 project to a godaddy windows shared hosting with php5.3 support and fixed it by providing write permission to the symfony2 directories and creating an iis virtual directory for the symfony project directory.
For me this was caused because I wasn't sure where a blob of config was added to my config.yml and removed it because I didn't know what it did :)
So I downloaded a fresh copy of symfony2 and realized that the blob of code comes by default on a fresh install, so I put it back in and it all works. Here's what I had removed and I fixed the problem by putting it back in:
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: %kernel.root_dir%/Resources/java/compiler.jar
#yui_css:
# jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
then answer is in the routing.yml
there is a resource in there that was probably disabled and the reference is left.