-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add doc to override app/Resources
location
#7228
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
Comments
Imported resources should be relative to the resource where the import is done. So this looks weird to me. |
@stof I personally changed it slightly to not have relative path as I was afraid people would get confused by it: # resources/config/routing.yml
app:
resource: '@Resources/../src/Infrastructure/Action'
type: 'annotation' // app/AppKernel.php
class AppKernel
{
//...
/**
* @inheritdoc
*/
public function locateResource($name, $dir = null, $first = true)
{
if (preg_match('/^@Resources/', $name)) {
$name = __DIR__.'/../resources/';
}
if (__DIR__.'/Resources' === $dir) {
$dir = realpath(__DIR__.'/../resources');
}
return parent::locateResource($name, $dir, $first);
}
} |
I'd add this to this article: "How to override anything in Symfony" We have some articles about overriding things in bundles ... but I'm not sure if we have that other article (which could explain how to override the location of the Doctrine entities, the location of cache/ and logs/, etc.) |
@javiereguiluz at least some are covered by https://speakerdeck.com/saro0h/symfonylive-san-francisco-2015-overriding-symfony-in-a-million-ways besides the doc |
Let's ask @wouterj, @xabbuh and @weaverryan if they think it's a good idea to create a "How to override everything in Symfony" article to explain all of that in a single article. Thanks! |
I think it's not needed anymore with #21231 |
@javiereguiluz should I close the issue as symfony/symfony#21231 fixes it or should be keep it for a "Override everything" page for which a few things are missing? |
@theofidry I agree that we should close this because of symfony/symfony#21231. Thanks! |
For a project of mine, I moved
app/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:
In a regular application, this relative path is being located from
app/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 a
app/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 the
file_locator
service: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:
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.
The text was updated successfully, but these errors were encountered: