1

I've required vsn4ik/bootstrap-checkbox in my Symfony project.

How do I now access to the javascript file it contains?

The only way was:

 {% javascripts
    '%kernel.root_dir%/vendor/vsn4ik/bootsrap-checkbox/js/bootstrap-checkbox.js'
    filter='?uglifyjs2'
 %}

But PHPStorm won't recognize it. Says 'missing asset'. It does work in the web app.

Also when I do php bin/console asset:install it won't install anything.

2
  • %kernel.root_dir%/../vendor/vsn4ik/bootsrap-checkbox/js/bootstrap-checkbox.js Commented Mar 16, 2017 at 8:27
  • asset:install will only install assets from dependencies that are place in the public resources directory. Seeing the path your requiring, the javascript file is placed somewhere else and thus will not be installed as an asset. Commented Mar 16, 2017 at 8:31

1 Answer 1

1

I don't use checkbox but I use the bootstrap slider like this:

assets.yml

assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        [ AppBundle ]

    filters:
        cssrewrite: ~
        scssphp:
            formatter: 'Leafo\ScssPhp\Formatter\Compressed'
        jsqueeze: ~
    assets:
        bootstrap_js:
            inputs:
                - "%kernel.root_dir%/../vendor/twitter/bootstrap/dist/js/bootstrap.js"
            filters: [ jsqueeze ]

        jquery:
            inputs:
                - "%kernel.root_dir%/../vendor/components/jquery/jquery.js"
            filters: [ jsqueeze ]

        slider_js:
            inputs:
                - "%kernel.root_dir%/../vendor/seiyria/bootstrap-slider/dist/bootstrap-slider.min.js"
            filters: [ jsqueeze ]
        slider_css:
            inputs:
                - "%kernel.root_dir%/../vendor/seiyria/bootstrap-slider/css/bootstrap-slider.css"
            filters: [cssrewrite, scssphp]

and then in my twig files:

{% javascripts '@jquery' '@bootstrap_js' '@slider_js' %}
    <script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}

I'm sure you can use the same approach in your usecase

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.