braincrafted / bootstrap-bundle

BraincraftedBootstrapBundle integrates Bootstrap into Symfony2 by providing templates, Twig extensions, services and commands.
http://bootstrap.braincrafted.com
MIT License
398 stars 181 forks source link

Fatal error when using custom variables.less #427

Closed kingkero closed 8 years ago

kingkero commented 8 years ago

I wanted to add a custom variables.less. However, braincrafted:bootstrap:generate returns this error

[Symfony\Component\Debug\Exception\FatalThrowableError]
Fatal error: Call to undefined method appDevDebugProjectContainer::enterScope()

I use braincrafted/bootstrap-bundle v2.2.0, twbs/bootstrap v3.3.6, symfony/assetic-bundle v2.8.0 config as follows

assetic:
    debug: '%kernel.debug%'
    use_controller: '%kernel.debug%'
    filters:
        less:
            node: /usr/local/bin/node
            node_paths: [/usr/local/lib/node_modules]
            apply_to: "\\.less$"
        cssrewrite: ~

braincrafted_bootstrap:
    css_preprocessor: less
    jquery_path: "%kernel.root_dir%/../vendor/components/jquery/jquery.min.js"
    customize:
        variables_file: "%kernel.root_dir%/Resources/less/variables.less"
    auto_configure:
        assetic: true
        twig: true

(I know getting started suggests to use apply_to: "\.less$", this will break assetic:dump whereas apply_to: "\\.less$" does work fine for me). I tried with multiple variables.less files, also copied the bootstrap.less from twbs, none changed a thing.

Complete error message/trace

martin:myproject $ php bin/console braincrafted:bootstrap:generate -vvv
Found custom variables file. Generating...

  [Symfony\Component\Debug\Exception\FatalThrowableError]                          
  Fatal error: Call to undefined method appDevDebugProjectContainer::enterScope()  

Exception trace:
 () at /xxx/vendor/braincrafted/bootstrap-bundle/Braincrafted/Bundle/BootstrapBundle/Command/GenerateCommand.php:108
 Braincrafted\Bundle\BootstrapBundle\Command\GenerateCommand->executeGenerateBootstrap() at /xxx/vendor/braincrafted/bootstrap-bundle/Braincrafted/Bundle/BootstrapBundle/Command/GenerateCommand.php:80
 Braincrafted\Bundle\BootstrapBundle\Command\GenerateCommand->execute() at /xxx/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:256
 Symfony\Component\Console\Command\Command->run() at /xxx/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:807
 Symfony\Component\Console\Application->doRunCommand() at /xxx/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:186
 Symfony\Component\Console\Application->doRun() at /xxx/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:80
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /xxx/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:117
 Symfony\Component\Console\Application->run() at /xxx/bin/console:29

braincrafted:bootstrap:generate [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
marlenesco commented 8 years ago

I have the same thing, anyone can help?

php bin/console braincrafted:bootstrap:generate


assetic:
    filters:
        less:
            node: /usr/local/bin/node
            node_paths: [/usr/local/lib/node_modules]
            apply_to: '\.less$'
        cssrewrite: ~
    assets:
        bootstrap_css:
            inputs:
                - "%kernel.root_dir%/../web/less/bootstrap.less"
            filters:
                - less
                - cssrewrite
            output:  "css/style.css"

braincrafted_bootstrap:
    auto_configure:
        assetic: false
    assets_dir: "%kernel.root_dir%/../web/vendor/bootstrap"
    css_preprocessor: less
    icon_prefix: fa
    fontawesome_dir: "%kernel.root_dir%/../web/vendor/font-awesome"
    fonts_dir: "%kernel.root_dir%/../web/vendor/bootstrap/fonts"
    auto_configure:
        assetic: true
        twig: true
        knp_menu: true
        knp_paginator: true
    customize:
        variables_file: "%kernel.root_dir%/../web/less/variable.less"
        bootstrap_output: "%kernel.root_dir%/../web/less/bootstrap.less"

Thanks

sikofitt commented 8 years ago

Same here.

bin/console braincrafted:bootstrap:generate

Found custom variables file. Generating...
PHP Fatal error:  Call to undefined method appDevDebugProjectContainer::enterScope() in /home/eric/nobackup/bytes/bytes-web/vendor/braincrafted/bootstrap-bundle/Braincrafted/Bundle/BootstrapBundle/Command/GenerateCommand.php on line 108
Fatal error: Call to undefined method appDevDebugProjectContainer::enterScope() in /home/eric/nobackup/bytes/bytes-web/vendor/braincrafted/bootstrap-bundle/Braincrafted/Bundle/BootstrapBundle/Command/GenerateCommand.php on line 108

[Symfony\Component\Debug\Exception\UndefinedMethodException]                          
  Attempted to call an undefined method named "enterScope" of class "appDevDebugProjectContainer".        
"require": {
        "php": ">=5.5.9",
        "symfony/symfony": "3.0.*",
        "symfony/assetic-bundle": "^2.8",
        "symfony/twig-bundle": "^3.0",
        "symfony/swiftmailer-bundle": "^2.3",
        "symfony/monolog-bundle": "^2.8",
        "doctrine/orm": "^2.5",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/doctrine-cache-bundle": "^1.2",
        "sensio/distribution-bundle": "^5.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "^2.0",
        "friendsofsymfony/user-bundle":"~2.0.0-dev",
        "knplabs/knp-menu-bundle": "^2.1",
        "braincrafted/bootstrap-bundle": "dev-master",
        "twbs/bootstrap": "3.2.*",
        "jquery/jquery":  "1.11.*",
        "twig/twig": "^1.24"
    },

using dev-master, also tried with v2.1.*

For me the fix (although temporary of course) was changing line 107 of GenerateCommand.php from

if (Kernel::VERSION_ID >= 20500) {

to

if (Kernel::VERSION_ID >= 20500 && Kernel::VERSION_ID < 30000) {

Was enough to at least get me back to developing.

marlenesco commented 8 years ago

@sikofitt thanks, it's a dirty solution but now I can work. I had to comment entire if, my VERSION_ID = 30006; cause symfony update:

Line 107 in vendor/braincrafted/bootstrap-bundle/Braincrafted/Bundle/BootstrapBundle/Command/GenerateCommand.php

if (Kernel::VERSION_ID >= 20500) {
    //$container->enterScope('request');
    //$container->set('request', new Request(), 'request');
}

composer.json

"require": {
    "php": ">=5.5.9",
    "symfony/symfony": "3.0.*",
    "doctrine/orm": "^2.5",
    "doctrine/doctrine-bundle": "^1.6",
    "doctrine/doctrine-cache-bundle": "^1.2",
    "symfony/swiftmailer-bundle": "^2.3",
    "symfony/monolog-bundle": "^2.8",
    "sensio/distribution-bundle": "^5.0",
    "sensio/framework-extra-bundle": "^3.0.2",
    "incenteev/composer-parameter-handler": "^2.0",
    "symfony/intl": "^3.0",
    "braincrafted/bootstrap-bundle": "dev-master",
    "vectorface/whip": "^0.3.1",
    "symfony/assetic-bundle": "^2.8",
    "symfony/translation": "^3.0"
},
"require-dev": {
    "sensio/generator-bundle": "^3.0",
    "symfony/phpunit-bridge": "^3.0"
},

Thanks again

jabbergabber commented 8 years ago

Same here also - same issue but from running on windows so only thing different from above in config.yml is path for assetic node and node_paths. Symfony 3