In this page:
WebFiori is a developer-friendly framework built using PHP, a popular programming language, mostly for building websites and web applications. It provides the essential tools you need to get started building web applications, like:
Think of WebFiori as a toolbox that has the essential tools you need to get started. Additionally, it can be used for more complex tasks, like sending emails or running tasks in the background.
While WebFiori focuses on these core functionalities, it empowers you to build feature-rich web applications without getting lost in complex details.
Imagine you're building a website, and visitors come in wanting to see different things (like the "About Us" page or a product listing). Routing is like a map that tells the website where to find the right information for each visitor based on their request.
WebFiori's routing system offers a versatile approach compared to traditional MVC frameworks. Unlike traditional MVC routes that point to controller methods, WebFiori routes can target various resources:
WebFiori prioritizes developer freedom by not enforcing the use of specific classes or methods like some MVC frameworks. Developers have the flexibility to choose the most suitable approach for each route based on the desired functionality and code organization.
In essence, Routing system in WebFiori acts as a powerful and adaptable tool, allowing developers to construct the routes tailored to their specific needs without rigid structural constraints.
Code
// https://example.com/products/board-games/Chess
Router::page([
RouteOption::PATH => 'products/{category}/{sub-category}',
RouteOption::TO => 'ViewProductsPage.php'
]);
// https://example.com/
Router::page([
RouteOption::PATH => '/',
RouteOption::TO => 'Home.html'
]);
Router::addRoute([
RouteOption::PATH => '/class-route',
RouteOption::TO => MyPHPClass::class
]);
//Optional to use MVC
Router::addRoute([
RouteOption::PATH => '/api/add-user',
RouteOption::TO => UsersController::class,
RouteOption::REQUEST_METHODS => ['post', 'put'],
RouteOption::ACTION => 'addUser'
]);
For more information about routing, check here .
WebFiori implements a robust session management system independent of PHP's native session handling. This approach offers several advantages:
Code
// Start new session
SessionsManager::start('first-session');
//Pause first session and start new with duration = 5 minutes
SessionsManager::start('another-session', [
SessionOption::DURATION => 5
]);
//Resume the session 'first-session'
SessionsManager::start('first-session');
More information about sessions management here .
WebFiori's themes system empowers developers to create visually cohesive web applications. This system offers several benefits:
Code
namespace app\pages;
use webfiori\framework\Page;
use themes\myTheme\MyThemeCore;
class MyPage extends WebPage {
public function __construct() {
$this->setTheme(MyThemeCore::class);
}
}
For more information on how to use and create themes, check here .
WebFiori's template engine prioritizes clarity and ease of use, offering a streamlined approach to web page creation. While it may not boast the extensive feature set of other template engines, it excels in:
Code
<!--This is the template-->
<div class="container">
<!--PHP variable as placeholder-->
<p>Hello Mr. "<?= $name ?>"</p>
</div>
Code
$template = HTMLNode::fromFile('path/to/my/template.php', [
'name' => 'Ibrahim Ali'
]);
For more information on how to build web pages, check here .
WebFiori's middleware system gives developers the option to intercept and manipulate incoming requests before they reach the application's core logic. The use of middleware has various benefits that includes:
webfiori/framework/middleware/AbstractMiddleware
class as a base for efficient custom middleware creation.
By placing custom middleware in the folder
[APP_DIR]/middleware
of the application, WebFiori automatically registers and integrates all middleware in that folder.
For more information on middleware, check here .
WebFiori's scheduler system allows developers to automate background tasks, enhancing application efficiency. This functionality ensures seamless execution of essential processes, even in the absence of user interaction. The key benefits of the system includes:
By leveraging the
webfiori/framework/scheduler/AbstractTask
class as a foundation, developers can effortlessly create custom background tasks. Simply place your implemented task class within the designated
[APP_DIR]/tasks
folder, allowing WebFiori to automatically discover and register it for seamless integration.
For more information about creating background jobs, check here .
WebFiori provides developers with the option to implement seamless and user-centric email communication within their web applications. This functionality simplifies the process of sending professional-looking HTML notifications, ensuring users remain informed and engaged. The main key advantages are:
webfiori/framework/EmailMessage
facilitates the creation and transmission of HTML email content.
Code
$message = new EmailMessage('no-reply');
$message->setSubject('This is a Test Email');
$message->addTo('user@example.com','Blog User');
$paragraph = $message->insert('p');
$paragraph->text('This is a welcome message.');
$this->insert(HTMLNode::fromFile('email-template.php'))
$message->send();
For more information about how to use mailing system, check here .
WebFiori equips developers with a suite of built-in commands designed to expedite the development process. These commands can streamline common tasks, saving valuable time and effort.
Furthermore, WebFiori allows for custom commands creation which are tailored to specific project needs. These custom commands seamlessly integrate into the framework, allowing for efficient execution and enhanced development workflows.
By leveraging both pre-built and custom commands, developers using WebFiori can significantly accelerate development cycles, fostering increased productivity and project efficiency.
For more information about this feature, check here
WebFiori streamlines database interaction for developers by offering built-in support for schema and query creation, specifically tailored for MySQL and SQL Server databases. This functionality fosters efficient development workflows and simplifies database management.
WebFiori's commitment to developer freedom extends to database management. While offering built-in functionalities, it remains adaptable to integrate seamlessly with alternative tools and libraries such as the use of native database drivers or the use of PDO (PHP Data Objects), empowering you to craft tailored solutions for your project demands.
For more information about this feature, check here .
Web services play a crucial role in establishing communication channels between various application components, including front-end and back-end logic. While commonly utilized to connect web pages with the back-end, they can be integrated with diverse other front-end systems which are hosted in the web.
WebFiori leverages the library
WebFiori HTTP
to empower developers with robust web service functionalities. Implementing these services is straightforward, requiring developers to extend the pre-defined
webfiori\http\AbstractWebService
class. This approach promotes efficient development and fosters the creation of well-structured web services.
For more information on web services, check here .
Next: Installation