Core Concepts
Discover the foundations and powerful features of Yabasi Framework
MVC Architecture
Utilizes the industry-standard Model-View-Controller (MVC) architectural pattern for modern web applications:
Models
Represents your data structure and manages database interactions.
Views
Handles presentation logic and renders the user interface.
Controllers
Processes requests by mediating between Models and Views.
Dependency Injection
Powerful Dependency Injection Container automatically manages class dependencies, enables loosely coupled code, and enhances testability.
namespace App\Controllers;
class UserController
{
public function __construct(
private UserService $userService,
private Logger $logger,
private Cache $cache
) {
// Dependencies are automatically injected
}
public function index()
{
$users = $this->userService->getAllUsers();
$this->logger->info('Users listed');
return $this->cache->remember('users', 3600, fn() => $users);
}
}
The container automatically resolves class dependencies and injects all required services.
Service Providers
Service providers are central components that manage your application's bootstrap process. They handle service registration, event listeners, and route configurations.
namespace App\Providers;
use Yabasi\ServiceProvider\ServiceProvider;
class UserServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->app->singleton(UserRepository::class, function ($app) {
return new UserRepository($app->get(Database::class));
});
$this->app->bind(UserService::class, function ($app) {
return new UserService(
$app->get(UserRepository::class),
$app->get(Cache::class)
);
});
}
public function boot(): void
{
$this->loadRoutes('routes/users.php');
$this->loadViews('users');
$this->loadTranslations('users');
}
}
register() method registers service bindings to the container.
boot() method runs after all services have been registered.
Middleware
Provides mechanism for filtering and processing HTTP requests. Perform various operations before requests reach your route or controller.
ORM
Enables database operations with intuitive syntax. Provides object-oriented approach instead of writing raw SQL queries.
Event System
Listen and react to events occurring within your application. Facilitates communication between modules.
Facades
Provides static interface to classes in the service container. Maintains clean syntax while preserving testability.
Learn More
Explore our documentation for detailed information about these core concepts: