bgreenacre / env-paths
Provides paths for where to store things like cache, configs, data etc. given the environment and user that is running the application.
dev-main / 1.0.x-dev
2022-04-08 22:00 UTC
Requires
- php: ^7.2 || ^8.0
Requires (Dev)
- phpstan/phpstan: ^1.1
- phpunit/phpunit: ^7.5 || ^8.5 || ^9.5
- squizlabs/php_codesniffer: ^3.6
This package is auto-updated.
Last update: 2023-11-09 01:20:48 UTC
README
Provides paths for where to store things like cache, configs, data etc. given the environment and user that is running the application. Heavily inspired by the envPaths nodejs package and composer's way finding home folder of the user.
Requirements
- PHP (7.2+)
Usage
Example
$paths = Bgreenacre\EnvPaths\EnvPaths::getPaths('MyApp'); /** * - macOS: `~/Library/Application Support/MyApp-php` * - Windows: `%LOCALAPPDATA%\MyApp-php\Data` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-php\Data`) * - Linux: `~/.local/share/MyApp-php` (or `$XDG_DATA_HOME/MyApp-php`) */ echo $paths['data']; /** * - macOS: `~/Library/Caches/MyApp-php` * - Windows: `%LOCALAPPDATA%\MyApp-php\Cache` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-php\Cache`) * - Linux: `~/.cache/MyApp-php` (or `$XDG_CACHE_HOME/MyApp-php`) */ echo $paths['cache']; /** * - macOS: `~/Library/Preferences/MyApp-php` * - Windows: `%APPDATA%\MyApp-php\Config` (for example, `C:\Users\USERNAME\AppData\Roaming\MyApp-php\Config`) * - Linux: `~/.config/MyApp-php` (or `$XDG_CONFIG_HOME/MyApp-php`) */ echo $paths['config']; /** * - macOS: `~/Library/Logs/MyApp-php` * - Windows: `%LOCALAPPDATA%\MyApp-php\Log` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-php\Log`) * - Linux: `~/.local/state/MyApp-php` (or `$XDG_STATE_HOME/MyApp-php`) */ echo $paths['log']; /** * - macOS: `/var/folders/jf/f2twvvvs5jl_m49tf034ffpw0000gn/T/MyApp-php` * - Windows: `%LOCALAPPDATA%\Temp\MyApp-php` (for example, `C:\Users\USERNAME\AppData\Local\Temp\MyApp-php`) * - Linux: `/tmp/USERNAME/MyApp-php` */ echo $paths['temp'];
License
This library is licensed under the MIT License - see the LICENSE file for details.