Skip to content

[AssetMapper] asset not loaded on subdirectory on subdir/index.php/assets  #58234

Open
@tito10047

Description

@tito10047

Symfony version(s) affected

6.4

Description

I have legacy project where we use symfony, so we have this directory structure:

  • project-dir
    • assets
    • src
    • public

Base url is target to project-dir where we have legacy code, and when we want call symfony we use url https://rds.wip/public/app_dev.php
So legacy project is on url https://rds.wip/app.asp and symfony is on https://rds.wip/public/app_dev.php

Today we want add asset mapper. but we have problem.

I'm set this to configuration

framework:
  asset_mapper:
    public_prefix: '/public/app_dev.php/assets/'

So import map in html is rendered correctly like /public/app_dev.php/app-1294d0b567c64a5db4f948b1c4cc6b94.js this is correct.
Bud symfony won't load this file.

Problem is here https://github.com/symfony/symfony/blob/7.2/src/Symfony/Component/AssetMapper/AssetMapperDevServerSubscriber.php#L122
getPathInfo return /app-1294d0b567c64a5db4f948b1c4cc6b94.js what is not start as /public/app_dev.php/assets/ described in asset_mapper.yaml

How to reproduce

symfony new asset-mapper --version="6.4.*" --webapp

create file app_dev.php in root directory

<?php
header("Location: /public/app.php");
exit;
#composer.json
    #...
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "6.4.*"
        },
        "symfony-web-dir": "./public",
        "public-dir": "./",
        "symfony-assets-install": "absolute"
    },
    #...

php bin/console make:controller Default

symfony server:start -d

go to https://127.0.0.1:8003/public/app.php/default

see imports. its wrong and not working

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions