3

I have been using Symfony since the start of the 3.x era, and am looking to create new sites on 4.x. It seems OK at first glance (just looking at the demo site), however, I'm not liking the idea of webpack encore.

When I installed the demo, it has issues as links are screwed up due to the sub-folder the project is in. I found out this is because I need to update settings in webpack encore, however, I can not deploy the changes as I do not have node.js installed, I run apache.

Most cpannel hosting currently does not support node.js, so it seems silly to have a reliance on node.js! I know I can do the deploy on a local server and then just send the deployed version up to the online server, but that can just be asking for problems, I want to do all development in an environment similar to the production environment.

Because of this I am looking at options in Symfony 4 to do asset management that will not need another server environment like node.js (or even yarn). I used assetic in the past, but support for it in Symfony 4 has been dropped. I want something that is easy to set up and use.

1 Answer 1

1

You can still go with assetic if you're not confortable with the node.js thing (which is understandable).

From symfony's doc :

Assetic is a pure PHP library that helps to process & optimize your assets (similar to Encore). Even though we recommend using Encore, Assetic still works great

Ref link : https://symfony.com/doc/current/frontend.html

Drawback being that you can't be sure whether or not it will still work with SF's next majors updates, I agree, but odds are new solutions will appear in the future, since you're not the only one complaning about it.


To follow up with your comments, with the use of the assets section of the configuration to make him fetch files wherever you want, I was thinking about something like (with proper rights given to folders) :

assetic:
/* ... */
    read_from:        %kernel.root_dir%/../build
    write_to:         %kernel.root_dir%/../build
/* ... */
    assets:
        common:
            inputs:
                - %kernel.root_dir%/../assets/js/your_file1.js
                - %kernel.root_dir%/../assets/js/your_file2.js
        isolatedFileExample:
            inputs:
                - %kernel.root_dir%/../assets/js/your_file3.js

Didn't test it though, keep us updated about your tests. Might be of some interest.

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

8 Comments

I didn't notice that paragraph, but when you go to the assetic documentation (for version 4.0 - symfony.com/doc/current/frontend/assetic.html) it just says it recommends not to use it. I will see if assetic will work in 4.x, but I don't imagine it would be set up to use the new directory structure (assets etc). I'm also hesitant to implement it as it could stop working with any upgrade.
Another place to keep an eye on this is github.com/symfony/assetic-bundle/issues/453
You can configure the source & destination directory ( see symfony.com/doc/3.3/reference/configuration/assetic.html ). Nice addition @MicWit
If you mean the read_from and write_to, I'm pretty sure the read_from has to be in the public (was web) directory. I will see if I can get it to work with the assets directory tomorrow.
OK, so it seems that assetic wont even install in Symfony 4.x, as it does not satisfy composer requirements. This is going to require an update to the assetic package on github to make it install, let alone work. The 4.x versions need to be added as compatible for composer.
|

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.