0

I am creating a Symfony Bundle where I have my commands, entities and all the logic that I need.

But in one of my commands I need to store files in /web/bundles/mybundle/images.

I've been googling a lot and I can't find anyway to get my bundle web root directory from a command.

Is there any Symfony function to get my bundle web root directory?

Darragh Enright
  • 13,676
  • 7
  • 41
  • 48
iVela
  • 1,160
  • 1
  • 19
  • 40
  • A related question, with some approaches that might be useful, although there doesn't seem to be a particularly tidy way to do so: http://stackoverflow.com/questions/9265788/how-to-get-the-server-path-to-the-web-directory-in-symfony2 – Darragh Enright Feb 22 '14 at 18:20
  • Thanks, I've already seen that question, but I think is some kind of "ugly" approach :) – iVela Feb 22 '14 at 18:43
  • Check the source code for the assets:install command. That sounds like what you are trying to do. – Cerad Feb 22 '14 at 18:57

1 Answers1

0

There is nothing in the Symfony2 core which will give you directly the path of your web directory...

One possible solution:

$path = realpath($this->container->getParameter('kernel.root_dir').'/../web');

egeloen
  • 5,844
  • 1
  • 27
  • 38