Nginx config example and relative path

This commit is contained in:
Pablo Ferreiro 2022-01-03 14:32:35 +01:00
parent 3dd723309d
commit 477efe8486
No known key found for this signature in database
GPG key ID: 41FBCE65B779FA24
3 changed files with 34 additions and 5 deletions

View file

@ -12,11 +12,36 @@ Then you can run it using for example the PHP Development Server with:
php -S localhost:8080
```
## Configuration
### .env
Move the .env.example file to .env and modify it.
### Apache
If you are using Apache you don't have to do anything more
### Nginx
Add the following to your config (you can modify the tiktok-viewer part if you have or not a subdir):
```
location /tiktok-viewer {
return 302 $scheme://$host/tiktok-viewer/;
}
location /tiktok-viewer/ {
try_files $uri $uri/ /tiktok-viewer/index.php?$query_string;
}
location /tiktok-viewer/.env {
deny all;
return 404;
}
```
## Known issues
* Right now there is an error when trying to fetch the desired user, there is already a pull request not merged yet fixing this issue on the TikTokApi repo, you can check it out [here](https://github.com/ssovit/TikTok-API-PHP/pull/43)
## TODO
* Allow searching for just one video using the ID
* Code cleanup
## Credits
* [TikTok-API-PHP](https://github.com/ssovit/TikTok-API-PHP)

View file

@ -9,7 +9,7 @@ $dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
function getSubdir(): string {
return $_ENV['APP_SUBDIR'] ? $_ENV['APP_SUBDIR'] : '/';
return $_ENV['APP_SUBDIR'] ? $_ENV['APP_SUBDIR'] : '';
}
function getApi(array $proxy_elements): \Sovit\TikTok\Api {
@ -25,13 +25,17 @@ function getApi(array $proxy_elements): \Sovit\TikTok\Api {
}
function getLatte(): \Latte\Engine {
$subdir = getSubdir();
$latte = new Latte\Engine;
$latte->setTempDirectory('./cache/views');
$latte->addFunction('assets', function (string $name, string $type) {
$subdir = getSubdir();
$latte->addFunction('assets', function (string $name, string $type) use ($subdir) {
$path = "{$subdir}/{$type}/{$name}";
return $path;
});
$latte->addFunction('path', function (string $name) use ($subdir) {
$path = "{$subdir}/{$name}";
return $path;
});
return $latte;
}

View file

@ -9,8 +9,8 @@
<div id="navbar-menu" class="navbar-menu">
<div class="navbar-start">
<a href="./home" class="navbar-item">Home</a>
<a href="./settings" class="navbar-item">Settings</a>
<a href="{path('home')}" class="navbar-item">Home</a>
<a href="{path('settings')}" class="navbar-item">Settings</a>
</div>
</div>
</nav>