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

Move the assets folder to public/assets #7094

Open
wants to merge 17 commits into
base: 5.x
Choose a base branch
from

Conversation

leofeyer
Copy link
Member

@leofeyer leofeyer commented Apr 5, 2024

Implements #7093

With these surprisingly few changes, we can get rid of the assets directory in the project root, as the assets and Contao components are installed directly in the public/assets folder.

I know that we originally wanted to install the Contao components in public/components, but that would break all existing references in $GLOBALS['TL_CSS'], $GLOBALS['TL_JAVASCRIPT'] and so on. The current solution is almost 100% backwards compatible because no paths change at all.

@leofeyer leofeyer added this to the 5.4 milestone Apr 5, 2024
@leofeyer leofeyer self-assigned this Apr 5, 2024
@leofeyer leofeyer requested a review from ausi April 5, 2024 15:53
@leofeyer leofeyer linked an issue Apr 5, 2024 that may be closed by this pull request
@leofeyer leofeyer requested review from a team and removed request for ausi May 8, 2024 11:03
@aschempp
Copy link
Member

How does this handle the case that any existing Contao installation has contao-component-dir set to assets and not public/assets?

@leofeyer
Copy link
Member Author

There are two possible solutions:

  1. We update the composer.json file in the manager (preferred).
  2. We keep symlinking the assets directory if contao-component-dir is set to assets.

Copy link
Member

@ausi ausi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should improve BC a bit, otherwise this is the way to go IMO 👍

core-bundle/contao/classes/PurgeData.php Show resolved Hide resolved
core-bundle/contao/library/Contao/Combiner.php Outdated Show resolved Hide resolved
core-bundle/contao/library/Contao/Image.php Show resolved Hide resolved
core-bundle/contao/library/Contao/Image.php Outdated Show resolved Hide resolved
core-bundle/tests/Contao/CombinerTest.php Outdated Show resolved Hide resolved
@leofeyer
Copy link
Member Author

How does this handle the case that any existing Contao installation has contao-component-dir set to assets and not public/assets?

@aschempp I have added a BC layer in e41594b. I would still prefer the manager to update the composer.json file, if that‘s possible.

@richardhj
Copy link
Member

In #7093 we talked about that the assets and public/assets folders are reserved by the Symfony framework.
I guess the solution, for those using a Symfony app, is to use a different folder for Symfony's version of assets..?

Is becoming compatible with symfony/asset-mapper not an alternative goal here?

@leofeyer
Copy link
Member Author

leofeyer commented May 27, 2024

It is, and that‘s exactly what the pull request does. After it has been merged, Contao will no longer use the assets folder. But of course, public/assets must be shared by Contao and Symfony to avoid BC breaks.

assets/                <-- available for the Symfony asset mapper

public/assets/
    ace/               <-- Contao component
    css/               <-- Contao
    images/            <-- Contao
    js/                <-- Contao
    styles/            <-- Symfony
    app.js             <-- Symfony

Anything beyond that can only be done in Contao 6.

@richardhj
Copy link
Member

If there are no naming conflicts, that would work fine! Otherwise one could always also change the output folder of asset mapper. So two promising paths after the PR was merged

@leofeyer leofeyer requested a review from ausi May 27, 2024 10:16
Copy link
Member

@ausi ausi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need something that actively deletes an already existing symlink from /public/assets to /assets?
With a check like !$this->symlinkAssets && is_link(Path::join($this->webDir, 'assets'))?

core-bundle/contao/library/Contao/Combiner.php Outdated Show resolved Hide resolved
leofeyer and others added 2 commits May 28, 2024 09:57
Co-authored-by: Martin Auswöger <martin@auswoeger.com>
@leofeyer
Copy link
Member Author

Added in 742e647.

Co-authored-by: Martin Auswöger <martin@auswoeger.com>
ausi
ausi previously approved these changes May 28, 2024
Copy link
Member

@ausi ausi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉
(But I did not test it manually)

@leofeyer
Copy link
Member Author

leofeyer commented May 28, 2024

I have tested it extensively and found another bug: ce48ebc Now everything should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop using the assets folder
4 participants