Skip to content

Commit a0e6b1e

Browse files
committed
Add example for installing via composer
1 parent c74bcee commit a0e6b1e

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

example_embedded_version.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Example: embedding phpCacheAdmin in your own website when installed via Composer.
4+
*/
5+
6+
declare(strict_types=1);
7+
8+
use RobiNN\Pca\Admin;
9+
use RobiNN\Pca\Config;
10+
11+
require __DIR__.'/../vendor/autoload.php';
12+
13+
/*
14+
* Configuration. Either:
15+
* - copy vendor/robinn/phpcacheadmin/config.dist.php to phpcacheadmin.config.php and set 'pcapath' & 'url', or
16+
* - set them in a .env file (requires vlucas/phpdotenv).
17+
*
18+
* 'pcapath' => '/assets/phpcacheadmin/', // where the assets (css, js, icons) are served from
19+
* 'url' => '/phpcacheadmin', // where this script is mounted
20+
*
21+
* Keep the config file outside vendor/ so Composer updates never overwrite it.
22+
*/
23+
Config::setConfigPath(__DIR__.'/phpcacheadmin.config.php');
24+
Config::loadDotenv(__DIR__); // Only needed for the .env option (requires vlucas/phpdotenv).
25+
26+
/*
27+
* Authentication is optional - you'll usually place the dashboard behind your website's own secured route.
28+
* If you don't, enable the built-in auth by uncommenting the line below and setting `authusers` in the config.
29+
*/
30+
//RobiNN\Pca\Auth::check();
31+
32+
echo (new Admin())->render();

src/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static function reset(): void {
3535
/**
3636
* Load environment variables from .env files.
3737
*
38-
* Requires vlucas/phpdotenv (composer require vlucas/phpdotenv).
38+
* Requires vlucas/phpdotenv.
3939
*
4040
* Real environment variables (e.g., set by Docker) always take precedence over the values defined in .env files.
4141
*/

0 commit comments

Comments
 (0)