Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Why are assets enabled by default? #17

Closed
javiereguiluz opened this issue Apr 3, 2017 · 13 comments
Closed

[Question] Why are assets enabled by default? #17

javiereguiluz opened this issue Apr 3, 2017 · 13 comments

Comments

@javiereguiluz
Copy link
Member

javiereguiluz commented Apr 3, 2017

If I create a Symfony app with Flex and then install the cli package to access to Symfony commands, I see the following:

$ ./bin/console

Symfony 3.3.0-DEV (kernel: src, env: dev, debug: true)

Usage:
  command [options] [arguments]

...

Available commands:
  about                   Displays information about the current project
  help                    Displays help for a command
  list                    Lists commands

 assets
  assets:install          Installs bundles web assets under a public web directory

 cache
  ...

Why is assets:install command enabled? I didn't expect to see it unless I enable/install assets support explicitly.

@fabpot
Copy link
Member

fabpot commented Apr 3, 2017

assets:install has nothing to do with the asset components. It's to install bundle assets under web/

@fabpot fabpot closed this as completed Apr 3, 2017
@javiereguiluz
Copy link
Member Author

You are right. But Symfony Flex no longer makes assumptions about the app you develop (that's why we don't include a "Welcome Page" or the server:* commands). So why should we include a utility to manage web assets? It's not needed when developing APIs, web servers, console apps, etc.

@fabpot
Copy link
Member

fabpot commented Apr 4, 2017

@javiereguiluz That's correct. This command could be moved from FrameworkBundle to elsewhere... but where? I didn't find a good place, that's why I kept it here. What we could do is to only enable it when there is at least one bundle with assets, but not sure if this could be practical or even desirable. WDYT?

@fabpot fabpot reopened this Apr 4, 2017
@ro0NL
Copy link

ro0NL commented May 3, 2017

Perhaps considerable.. should SF offer this (frontend) solution at all? Looking at most of our projects today.. we dont really use/need it anymore since we moved to webpack and frontend specific commands/tasks (think gulp).

For the same reason deprecating templating, classloader and such. We have better tools :)

@fabpot
Copy link
Member

fabpot commented May 4, 2017

@ro0NL How do you let bundles expose some public assets then?

@Pierstoval
Copy link
Contributor

@fabpot with such tools you don't have bundles that expose public assets. Everything is private and compiled by tools and task runners and dumped into the web dir, most of the time in a place which is covered by a .gitignore instruction to avoid versioning compiled files.

It's like if you have src/AppBundle/Resources/less/main.less and you compile it and dump it to web/css/main.css. Nothing public from the bundle is exposed.

That's what I do for my projects, even for images, I'm using only Gulp with this Gulpfile which uses a simple configuration array and already has all needed preconfigured tasks for most cases, and I even use the copy/paste command to get data from my node_modules and put them into a specific web directory. This keeps a total control over web assets that can be compiled as we want.

I don't know about webpack, but it is basically the same thing: you specify your sources and dump the modules in the web directory, so the sources are never public, and anything which should be "source" is always dumped into the web directory to ensure a "production-ready" assets management

@ro0NL
Copy link

ro0NL commented May 4, 2017

We dont :) well.. our gulp task just scrapes bundles, something like

glob.sync('@(vendor|src)/**/*@(B|b)undle/Resources/public/assets/gulp.config.js')

But you really can do any setup you want. The current assets:install is more or less an opinionated setup, and can also be achieved writing a gulp task.

I'm also thinking to move assets+templates from bundles to the app layer. Without assets:install there's no default strategy available for opensource bundles to reference owned assets in owned templates. But that's exactly one of my goals.. fully separate the view layer. And avoid depending on "global" templates and such...

For webpack, we parse the generated stats.json that allows us to implement something like

{{ webpack_asset('path/to/assets/in/web', 'filename', 'ext'[, 'sf_asset_package_name']) }}

path/to/assets/in/web is basically a build directory, where dist files are written to.

@umulmrum
Copy link

My 2 cents: Please do not increase the project setup cost and the learning curve height by introducing a requirement for external tools (especially node.js-based setups). Basic asset handling is great and there's nothing against replacing it in a project at will.

@ro0NL
Copy link

ro0NL commented May 12, 2017

Agee we can keep the current tooling available for basic asset handling, probably a lot of projects/bundles are using it. But @javiereguiluz has a point we should be able to decouple from it.

A way to do it is to further strip down the framework bundle into smaller bundles, i.e. AssetsBundle, FormBundle, etc. That would be a lot more flex ible right?

@Koc
Copy link

Koc commented Aug 4, 2017

Same question for routing configuration. For cli-only application routing not needed

@fabpot
Copy link
Member

fabpot commented Aug 4, 2017

@Koc the skeleton and the recipes are web-oriented. If you want to create a CLI tool, there is no need for anything. A regular composer req symfony/console is enough.

@Koc
Copy link

Koc commented Aug 4, 2017

we need doctrine infrstructure and httpplug

@javiereguiluz
Copy link
Member Author

Closing because this is not simple to fix (where should we move this into?) but it could be fixed in the future as explained by @ro0NL if Symfony code continues splitting the old FrameworkBundle into smaller pieces. Thanks!

tgalopin pushed a commit to tgalopin/flex that referenced this issue Dec 3, 2020
…aviereguiluz)

This PR was squashed before being merged into the master branch (closes symfony#17).

Discussion
----------

Proposed a help note for the DB_URL  config format

I'm not sure about this, but given that the URL format is so new to most developers, should we add a help note like this one?

Commits
-------

193b15b Proposed a help note for the DB_URL  config format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants