Skip to content

Commit

Permalink
Merge pull request #678 from odan/gh-pages
Browse files Browse the repository at this point in the history
Update section "Run From a Sub-Directory"
  • Loading branch information
akrabat committed Aug 28, 2023
2 parents 3050917 + 4a4e19a commit 4f0867c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docs/v4/start/web-servers.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,22 @@ url.rewrite-if-not-file = ("(.*)" => "/index.php/$0")
This assumes that Slim's `index.php` is in the root folder of your project (www root).

## Run From a Sub-Directory
If you want to run your Slim Application from a sub-directory in your Server's Root instead of creating a Virtual Host, you can configure ``$app->setBasePath('path-to-your-app')`` right after the ``AppFactory::create()``.
Assuming that your Server's Root is ``/var/www/html/`` and path to your Slim Application is ``/var/www/html/my-slim-app`` you can set the base path to ``$app->setBasePath('/my-slim-app')``.

If you want to run your Slim Application from a sub-directory in your Server's Root instead of creating a Virtual Host,
you can configure `$app->setBasePath('/path-to-your-app');` right after the `AppFactory::create();`.
Assuming that your Server's Root is `/var/www/html/` and path to your Slim Application is `/var/www/html/my-slim-app`
you can set the base path to `$app->setBasePath('/my-slim-app');`.

```php
<?php

use Slim\Factory\AppFactory;
use Slim\Middleware\OutputBufferingMiddleware;
// ...

$app = AppFactory::create();
$app->setBasePath('/my-slim-app');

// ...

$app->run();
```

0 comments on commit 4f0867c

Please sign in to comment.