1

I am completely new to Twig. I have a Twig project, but I do not manage to configure paths to css and js file in the project. The packages I have installed (as in the composer.json file) are:

     "require": {
    "twig/twig": "~1.0",
    "symfony/twig-bundle": "^3.1",
    "symfony/asset": "^3.1",
    "symfony/templating": "^3.1",
    "symfony/yaml": "^3.1"
}

In the project I have a folder "vendor" (where all these packages are found) and folder "web", in which I want to put my folders "views", "resources/images" and "resources/styles".

However, when I try to run in cmd the command:

    php app/console assets:install web --symlink

I get the error: Could not open input file: app/console.

What should I do to include a css file, or image, or js file in the most accurate way?

1 Answer 1

3

In Symfony version 3.x it was changed from app/console to bin/console.

Additionally you should follow the 3.x installation guide for Symfony Installer or for composer installation to ensure you have the desired library and bundles. As the console and directory structure are not automatically created when using Composer alone.

Your composer should consist of pretty much only symfony/framework-standard-edition instead of the individual components. Otherwise you will need to install the components manually, and setup any other dependencies and configurations to get them all to work together. http://symfony.com/components

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

3 Comments

So, your advice is to start by creating a project with Symphony installer and then adding Twig to it, not by just starting Composer and then installing Twig? As for bin/console, there is probably something wrong with the components in my project,as it returns the same error
Twig comes as a part of the symfony framework. As you're trying to use Symfony to manage your assets with the Symfony console (bin/console), it would be far easier to use the entire framework properly installed. Managing the individual components is a hassle (which is where you're at now). For example the twig-bundle can not be used without the Http-Kernel component and Framework Bundle. EG: symfony/symfony-standard. And can not be used without registering the bundle in your app/AppKernel.php file. See: github.com/symfony/symfony-standard/blob/master/app/…
As for using twig in general, it is perfectly fine as a standalone package. Just not using Symfony to manage your asset files, as it appears that Symfony was not properly installed in order to provide you with the console See: github.com/symfony/symfony-standard/blob/master/bin/console

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.