Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add doc to overrideapp/Resources location #7228

Closed
@theofidry

Description

@theofidry

For a project of mine, I movedapp/Resources intoresources to keep more in line with the company project structure. On the way I had a few quirks, namely with the routing.

When having the following:

# resources/config/routing.ymlapp:resource:'../../src/Infrastructure/Action'type:'annotation'

In a regular application, this relative path is being located fromapp/Resources so it should result inapp/Resources/../../src/Infrastructure/Action. Whilst the path does make sense (src/Infrastructure/Action exists),app/Resources does not exist so resolving this path e.g. withrealpath() will fail.

One could get around that by using the@AppBundle notation, but this notation is not usable with.. so ifAppBundle is not place at a higher level thansrc/Infrastructure/Action, e.g. when you havesrc/Infrastructure/Bundle/AppBundle.php, this trick cannot work.

When you get at that point, you either take the path of the least resistance and just create aapp/Resources/.gitkeep file and don't care or you are a stubborn sore loser and try to keep going.

So here's how I eventually got around that: First override thefile_locator service:

# resources/services.ymlservices:file_locator:class:Symfony\Component\HttpKernel\Config\FileLocatorarguments:            -'@kernel'            -'%kernel.root_dir%/../resources'

I don't know exactly where in the application this service is really used, but I do know it's used very early in the bootstrapping process so this in any case is not enough. Not finding a better solution, I changed:

// app/AppKernel.phpclass AppKernel{//.../**     * @inheritdoc     */publicfunctionlocateResource($name,$dir =null,$first =true)    {if (__DIR__.'/Resources' ===$dir) {$dir =realpath(__DIR__.'/../resources');        }returnparent::locateResource($name,$dir,$first);    }}

I'm not sure is there something more elegant that could be done neither if this should be documented. If it should let me know where I'll be happy to do a PR about it, if you feel it's not worth it just close the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp