Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added some documentation to Outside the web root chapter #122

Merged
merged 1 commit into from

2 participants

@nass600

No description provided.

@lsmith77
Owner

ok thx .. seems like we had some outdated docs there.

@lsmith77 lsmith77 merged commit c5a00f3 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 33 additions and 13 deletions.
  1. +33 −13 README.md
View
46 README.md
@@ -371,26 +371,46 @@ In case you need to add more logic the recommended solution is to either extend
## Outside the web root
When your setup requires your source images to live outside the web root, or if that's just the way you roll,
-you can override the DataLoader service and define a custom path, as the third argument, that replaces
-`%liip_imagine.web_root%` (example here in XML):
+you have to set the bundle's parameter `data_root` in the `config.yml` with the absolute path where your source images are
+located:
+
+``` yaml
+ liip_imagine:
+ data_root: /path/to/source/images/dir
+```
+
+Afterwards, you need to grant read access on Apache to access the images source directory. For achieving it you have
+to add the following directive to your project's vhost file:
``` xml
-<service id="liip_imagine.data.loader.filesystem" class="%liip_imagine.data.loader.filesystem.class%">
- <tag name="liip_imagine.data.loader" loader="filesystem" />
- <argument type="service" id="liip_imagine" />
- <argument>%liip_imagine.formats%</argument>
- <argument>%kernel.root_dir%/data/uploads</argument>
-</service>
+ <VirtualHost *:80>
+ <!-- Rest of directives like DocumentRoot or ServerName -->
+
+ Alias /FavouriteAlias /path/to/source/images/dir
+ <Directory "/path/to/source/images/dir">
+ AllowOverride None
+ Allow form All
+ </Directory>
+ </VirtualHost>
```
-One way to override a service is by redefining it in the services configuration file of your bundle.
-Another way would be by modifying the service definition from your bundle's Dependency Injection Extension:
+Another way would be placing the directive in a separate file living inside your project. For instance,
+you can create a file `app/config/apache/photos.xml` and add to the project's vhost the following directive:
-``` php
-$container->getDefinition('liip_imagine.data.loader.filesystem')
- ->replaceArgument(2, '%kernel.root_dir%/data/uploads');
+``` xml
+ <VirtualHost *:80>
+ <!-- Rest of directives like DocumentRoot or ServerName -->
+
+ Include "/path/to/your/project/app/config/apache/photos.xml"
+ </VirtualHost>
```
+This way you keep the file along with your code and you are able to change your files directory access easily or create
+different environment-dependant configuration files.
+
+Either way, once you have granted access on Apache to read the `data_root` files, the relative path of an image with this
+absolute path `/path/to/source/images/dir/logo.png` must be `/FavouriteAlias/logo.png` to be readable.
+
## Custom image loaders
The ImagineBundle allows you to add your custom image loader classes. The only
Something went wrong with that request. Please try again.