BearFramework\App\Assets::addDir

Registers a directory that will be publicly accessible.
public self addDir string $pathname )
Parameters
pathname
The directory name.
Returns
Returns a reference to itself.
Examples
Example #1 description
<?php require '../vendor/autoload.php';

use 
BearFramework\App;

// Constructs a new Bear Framework application.
$app = new App();

$app->routes
        
->add('/', function() { // Defines a handler for the application home page.
            
$response = new App\Response(); // Constructs a new response.
            
$response->content 'This is the home page!'// Sets the response content.
            
return $response// Returns the response.
        
})
        ->
add('/products/', function() { // Defines a handler for a request with a path matching "/products/"
            
$response = new App\Response(); // Constructs a new response.
            
$response->content 'This is the products page!'// Sets the response content.
            
return $response// Returns the response.
        
})
        ->
add('/products/?/', function(App\Request $request) { // Defines a handler for a request with a path staring with "/products/" followed by one more path segment.
            
$productSlug $request->path->getSegment(1); // Retrieves the value of the second segment.
            
$response = new App\Response(); // Constructs a new response.
            
$response->content 'This is the page for ' $productSlug '!'// Sets the response content.
            
return $response// Returns the response.
        
});

// Finds the response and send it to the client.
$app->run();
Location: ~/examples/Routes.php
See also
The is the class used to instantiate you application.
Checks if a data item key is valid.
Details
Location: ~/src/App/Assets.php
The information on this page is created for version 1.1 of Bear Framework and may not be applicable for other versions of the framework.