Closed lakhman closed 8 years ago
I can reproduce this issue with a fresh new symfony install.
(You can copy and paste this into your terminal in one go to get up and running with the same error).
PROJECT_NAME=webpack-adminlte && echo $PROJECT_NAME
WORKING_DIR=~/Sites && echo $WORKING_DIR
cd $WORKING_DIR
# Create a new symfony 3 project && enter it
symfony new $PROJECT_NAME && cd $PROJECT_NAME
# Install webpack-bundle
composer require maba/webpack-bundle
# Update AppKernel.php
cat <<'-EOF' > app/AppKernel.patch
--- a/app/AppKernel.php
+++ b/app/AppKernel.php
@@ -15,6 +15,7 @@ class AppKernel extends Kernel
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
+ new Maba\Bundle\WebpackBundle\MabaWebpackBundle(),
new AppBundle\AppBundle(),
];
-EOF
# Patch the AppKernel with our new bundle
patch -p1 -l < app/AppKernel.patch && rm app/AppKernel.patch
# Setup maba
yes | console maba:webpack:setup
# Make our entry file
mkdir -p app/Resources/assets && touch app/Resources/assets/main.js
# Compile the assets for the first time
console maba:webpack:compile --env=prod
# Fails here with the above error
# Why?
It parses all twig files found in /Resources/views
of each registered bundle.
SecurityBundle/Resources/views/Collector/security.html.twig
template is used for displaying information in web profiler, this is used only in development environment.
The twig function used in that template, profiler_dump
, is registered in WebProfilerBundle
, which is loaded only in dev
environment by default (in AppKernel
class).
Temporary solution would be to enable parsing twig templates only in some bundles/directories:
maba_webpack:
asset_providers:
-
resource:
- ApplicationBundle # or any other bundles, where webpack_asset function can be found
- AcmeHelloBundle
type: twig_bundles
-
resource: "%kernel.root_dir%/Resources/views"
type: twig_directory
I'll look into some permanent solution inside the bundle itself. Probably just ignoring twig files with such an issue would be the best solution - they would not render either way in that environment, so no point in getting possible entry points from them.
that worked, remember to clear your cache after updating (for prod), Thanks!
Yeah the solution to ignore these if they cause errors would be best, although perhaps we should display that to the user - we don't want to silently ignore errors (which may affect the user).
Awesome, that will do for now!
With last fix default configuration should do just fine.
With default monolog configuration logger's warnings are displayed in console, so any failures will be visible to the developer, too.
New option was added for suppress_errors
and set as default for prod
(non-dev
) environment. It ignores just those errors that can happen in this use-case.
Awesome, just updated, works great, thanks.
I've got this working in development, but when I run the compile command for production, I get the following error:
Main error:
Full output:
Any ideas why it's trying to load the collector when compiling for production? I've checked my configuration against the demo bundle of this project (which runs as expected). I can't seem to find any obvious differences. (Configuration is exactly the same - the default symfony config).