Marwa Framework provides path helper functions for generating application paths. URL generation for web routes uses the application’s base URL combined with the route path.
| Function | Description |
|---|---|
base_path() |
Application root directory |
public_path() |
Public web root |
storage_path() |
Storage directory |
config_path() |
Configuration directory |
resources_path() |
Resources directory |
views_path() |
Views directory |
routes_path() |
Routes directory |
database_path() |
Database directory |
module_path() |
Modules directory |
cache_path() |
Cache directory |
logs_path() |
Logs directory |
// Get paths
base_path(); // /var/www/myapp
base_path('config'); // /var/www/myapp/config
public_path('css/style.css'); // /var/www/myapp/public/css/style.css
storage_path('logs/app.log'); // /var/www/myapp/storage/logs/app.log
Since Marwa Framework uses standard route paths, construct URLs manually:
// Get the current request URL
$request = request();
$currentUrl = $request->getUri();
// Build URLs manually
$baseUrl = 'https://example.com';
$url = $baseUrl . '/users/' . $userId;
Reference routes by their defined paths:
// In views/templates
<a href="/users">Users</a>
<a href="/users//edit">Edit</a>
<form action="/posts" method="POST">
// In controllers (redirects)
return redirect('/dashboard');
return redirect('/users/' . $user->id);
// In responses
return redirect()->to('/login');
$baseUrl = '/products';
$query = http_build_query([
'category' => 'electronics',
'sort' => 'price',
'order' => 'asc',
]);
$url = $baseUrl . '?' . $query;
// /products?category=electronics&sort=price&order=asc
$url = '/docs#installation';
$url = '/api/users#response-format';
// Get current request path
$path = request()->getUri()->getPath();
// /users/profile
// Check if on specific path
if (request()->getUri()->getPath() === '/dashboard') {
// Active state
}
$uri = request()->getUri();
$fullUrl = (string) $uri;
// https://example.com/path?query=value
# In .env
APP_URL=https://example.com
ASSETS_URL=https://cdn.example.com
$appUrl = env('APP_URL', 'http://localhost');
// In templates - hardcode asset paths
<link rel="stylesheet" href="/css/app.css">
<script src="/js/app.js"></script>
<img src="/images/logo.png">
// With version/cache busting
<img src="/images/logo.png?v=1.0.1">
// Planned helper
asset('css/app.css'); // /css/app.css
asset('js/app.js'); // /js/app.js
The framework may support named routes in future versions:
// Route definition (when available)
Route::get('/users/{id}', [UserController::class, 'show'])->name('users.show');
// URL generation
route('users.show', ['id' => 123]); // /users/123
htmlspecialchars() for URL parameters containing user data