sFire PHP Framework

Paths

sFire stores all the directories as an absolute path in the sFire\Config\Path interface. You may use this interface to retrieve the paths for you to use in your application. For example, you may want to know the path to the upload directory to store all your users file submits.

In this section we will handle:

  • How to return a single path
  • How to return all the paths
  • What are the available paths
  • How to store a new directory as a path

Return path by name

You can retrieve a path by calling the get method. This method accepts a String or Array parameter and returns a String.

$modules = Path :: get('modules');
echo $modules;

Return all the paths

To retrieve all the paths, you should use the all method. This method will return an Array with all the paths

$paths = Path :: all();
print_r($paths);

Available paths

The available paths are listed below.

Key Description
root The root directory of you application
config Contains application config files like app.php and routes.php
public Directory that can be accessed from the internet
data Arbitrary data directory
cache Contains all the cache
cache-template Directory for all the template cache files
cache-translation Directory for all the translation cache files
cache-shared Directory for all other cache files
schedule Place all your schedules/cron jobs in this directory
log Arbitrary log directory
log-access Store all the access logs in this directory
log-error Store all the error logs in this directory
log-schedule Store all the schedule logs in this directory
session Store the session files in this directory
ssl You can place all the SSL/TSL certificates in this directory
upload Store all the files that clients submits in this directory
modules This directory contains all your application modules
vendor This directory should contain every vendor libraries

Adding new paths

To store a new path you can simply use the add method. This method accepts two parameters. The first parameter is the key, while the second parameter is the value. Both parameters should be a String.

Path :: add('www', '/var/www/');
Path :: get('www'); //Outputs "/var/www/"