A lightweight extension for managing application directory paths (such as application, public, and temporary directories) within a Nette-based project. Provides a simple way to access these paths via dependency injection.
- PHP >= 8.3
- Nette Framework
- Composer
composer require drago-ex/parameters
To enable the Parameters extension in your Nette project, add the following configuration to your neon file. This registers
the ParametersExtension and injects paths to the application, public, and temporary directories.
extensions:
- Drago\Parameters\DI\ParametersExtension(appDir: %appDir%, wwwDir: %wwwDir%, tempDir: %tempDir%)This will automatically inject the directory paths as services into your project.
Once registered, you can access the directory paths throughout your application using the following properties:
To get the path to your application's directory (usually the root directory of your app), use:
$this->appDir;To get the path to your public directory (e.g., the www or public directory):
$this->wwwDir;To get the path to the temporary directory (where cache or logs might be stored):
$this->tempDir;