Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019-present, Ibrahim BinAlshikh and contributors.
Copyright (c) 2019-present WebFiori Framework and contributors.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@

WebFiori is a modular, object-oriented PHP framework designed for building secure web applications and APIs. It provides a complete toolkit — routing, middleware, authorization, database management, job queues, and more — while remaining lightweight and free of heavy external dependencies.

## Motivation

WebFiori is designed around two architectural decisions:

1. **Self-contained ecosystem.** Each component (HTTP, database, cache, sessions, mail, queue, CLI, authorization) is an independent library with no external runtime dependencies. This eliminates transitive dependency conflicts and simplifies security auditing.

2. **Interface-driven extensibility.** Storage backends for sessions, cache, queues, and authorization are defined by interfaces. Swap implementations without modifying application code.

The framework provides the orchestration layer. The libraries can be used together as a full stack or independently in any PHP project.

## Requirements

- PHP 8.1 or later
Expand Down
2 changes: 1 addition & 1 deletion WebFiori/Framework/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2020 Ibrahim BinAlshikh
* Copyright (c) 2020-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
4 changes: 4 additions & 0 deletions WebFiori/Framework/AccessManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ public function can($user, string $permission, ?object $resource = null): bool {
$userId = is_object($user) && method_exists($user, 'getId') ? $user->getId() : $user;
$roles = $this->getUserRoles($userId);

if (empty($roles) && is_object($user) && method_exists($user, 'getRoles')) {
$roles = $user->getRoles();
}

$hasPermission = false;

foreach ($roles as $roleName) {
Expand Down
5 changes: 4 additions & 1 deletion WebFiori/Framework/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2019 Ibrahim BinAlshikh
* Copyright (c) 2019-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down Expand Up @@ -375,6 +375,9 @@ public static function getRunner() : Runner {
'\\WebFiori\\Framework\\Cli\\Commands\\FreshMigrationsCommand',
'\\WebFiori\\Framework\\Cli\\Commands\\SkipMigrationsCommand',
'\\WebFiori\\Framework\\Cli\\Commands\\StepMigrationsCommand',
'\\WebFiori\\Framework\\Cli\\Commands\\ServicesListCommand',
'\\WebFiori\\Framework\\Cli\\Commands\\RoutesCacheCommand',
'\\WebFiori\\Framework\\Cli\\Commands\\RoutesClearCommand',
];

foreach ($commands as $c) {
Expand Down
2 changes: 1 addition & 1 deletion WebFiori/Framework/AppBootstrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2020 Ibrahim BinAlshikh
* Copyright (c) 2020-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion WebFiori/Framework/Autoload/ClassInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2024 Ibrahim BinAlshikh
* Copyright (c) 2024-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion WebFiori/Framework/Autoload/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2020 Ibrahim BinAlshikh
* Copyright (c) 2020-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion WebFiori/Framework/Autoload/ClassLoaderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2020 Ibrahim BinAlshikh
* Copyright (c) 2020-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion WebFiori/Framework/ClassRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2020 Ibrahim BinAlshikh
* Copyright (c) 2020-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion WebFiori/Framework/Cli/CLITestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2024 Ibrahim BinAlshikh
* Copyright (c) 2024-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion WebFiori/Framework/Cli/Commands/CreateMigrationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2025 Ibrahim BinAlshikh
* Copyright (c) 2025-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion WebFiori/Framework/Cli/Commands/CreateSeederCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2025 Ibrahim BinAlshikh
* Copyright (c) 2025-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2025 Ibrahim BinAlshikh
* Copyright (c) 2025-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion WebFiori/Framework/Cli/Commands/InitMigrationsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2025 Ibrahim BinAlshikh
* Copyright (c) 2025-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2025 Ibrahim BinAlshikh
* Copyright (c) 2025-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2025 Ibrahim BinAlshikh
* Copyright (c) 2025-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
48 changes: 48 additions & 0 deletions WebFiori/Framework/Cli/Commands/RoutesCacheCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* This file is licensed under MIT License.
*
* Copyright (c) 2026-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
*
*/
namespace WebFiori\Framework\Cli\Commands;

use WebFiori\Cache\Cache;
use WebFiori\Cache\FileStorage;
use WebFiori\Cli\Command;
use WebFiori\Framework\Router\RouteCache;
use WebFiori\Framework\Router\Router;

/**
* CLI command to build the route cache.
*
* @author Ibrahim
*/
class RoutesCacheCommand extends Command {
public function __construct() {
parent::__construct('routes:cache', [], 'Build the route cache for production.');
}

public function exec(): int {
$cache = $this->createRouteCache();
$cache->setEnabled(true);
$count = $cache->build();
$this->success("Route cache built: $count route(s) cached.");

return 0;
}

private function createRouteCache(): RouteCache {
$storagePath = APP_PATH . 'Storage';

if (!is_dir($storagePath)) {
mkdir($storagePath, 0755, true);
}

return new RouteCache(new Cache(new FileStorage($storagePath)), true);
}
}
42 changes: 42 additions & 0 deletions WebFiori/Framework/Cli/Commands/RoutesClearCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/**
* This file is licensed under MIT License.
*
* Copyright (c) 2026-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
*
*/
namespace WebFiori\Framework\Cli\Commands;

use WebFiori\Cache\Cache;
use WebFiori\Cache\FileStorage;
use WebFiori\Cli\Command;
use WebFiori\Framework\Router\RouteCache;

/**
* CLI command to clear the route cache.
*
* @author Ibrahim
*/
class RoutesClearCommand extends Command {
public function __construct() {
parent::__construct('routes:clear', [], 'Clear the route cache.');
}

public function exec(): int {
$cache = $this->createRouteCache();
$cache->clear();
$this->success('Route cache cleared.');

return 0;
}

private function createRouteCache(): RouteCache {
$storagePath = APP_PATH . 'Storage';

return new RouteCache(new Cache(new FileStorage($storagePath)), true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2025 Ibrahim BinAlshikh
* Copyright (c) 2025-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion WebFiori/Framework/Cli/Commands/SchedulerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2019 Ibrahim BinAlshikh
* Copyright (c) 2019-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
55 changes: 55 additions & 0 deletions WebFiori/Framework/Cli/Commands/ServicesListCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/**
* This file is licensed under MIT License.
*
* Copyright (c) 2026-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
*
*/
namespace WebFiori\Framework\Cli\Commands;

use WebFiori\Cli\Command;
use WebFiori\Framework\Router\ServiceRouter;

/**
* CLI command to list all discovered services.
*
* @author Ibrahim
*/
class ServicesListCommand extends Command {
public function __construct() {
parent::__construct('services:list', [], 'List all auto-discovered API services.');
}

public function exec(): int {
$discovered = ServiceRouter::getDiscovered();

if (empty($discovered)) {
$this->info('No services discovered. Use ServiceRouter::discover() to register services.');

return 0;
}

$this->println('');
$this->println(sprintf(' %-15s %-45s %-10s %s', 'Name', 'Class', 'Type', 'Path'));
$this->println(str_repeat('-', 90));

foreach ($discovered as $name => $entry) {
$this->println(sprintf(
' %-15s %-45s %-10s %s',
$name,
$entry['class'],
$entry['type'],
$entry['path']
));
}

$this->println('');
$this->info('Total: ' . count($discovered) . ' service(s).');

return 0;
}
}
2 changes: 1 addition & 1 deletion WebFiori/Framework/Cli/Commands/StepMigrationsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2026 Ibrahim BinAlshikh
* Copyright (c) 2026-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion WebFiori/Framework/Cli/Commands/VersionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2019 Ibrahim BinAlshikh
* Copyright (c) 2019-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion WebFiori/Framework/Cli/Commands/WHelpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2019 Ibrahim BinAlshikh
* Copyright (c) 2019-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion WebFiori/Framework/Cli/Helpers/ClassInfoReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2019 Ibrahim BinAlshikh
* Copyright (c) 2019-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion WebFiori/Framework/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2020 Ibrahim BinAlshikh
* Copyright (c) 2020-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion WebFiori/Framework/EmailMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is licensed under MIT License.
*
* Copyright (c) 2020 Ibrahim BinAlshikh
* Copyright (c) 2020-present WebFiori Framework
*
* For more information on the license, please visit:
* https://github.com/WebFiori/.github/blob/main/LICENSE
Expand Down
Loading
Loading