PHPackages                             gabela/micro-framework - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. gabela/micro-framework

ActiveProject[Framework](/categories/framework)

gabela/micro-framework
======================

This the next big thing in the php frameworks community

1.4.8(1y ago)03MITPHP

Since Mar 5Pushed 1y ago4 watchersCompare

[ Source](https://github.com/gabela-framework/gabela)[ Packagist](https://packagist.org/packages/gabela/micro-framework)[ RSS](/packages/gabela-micro-framework/feed)WikiDiscussions main Synced yesterday

READMEChangelog (9)Dependencies (8)Versions (26)Used By (0)

[![gabela logo](https://private-user-images.githubusercontent.com/161472830/308537268-d3513f4b-da42-4126-b923-78839d9f87c8.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODMwMTc4OTcsIm5iZiI6MTc4MzAxNzU5NywicGF0aCI6Ii8xNjE0NzI4MzAvMzA4NTM3MjY4LWQzNTEzZjRiLWRhNDItNDEyNi1iOTIzLTc4ODM5ZDlmODdjOC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNzAyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDcwMlQxODM5NTdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04YTlkMWVkMGUwMjY5Njc3NDU0ZGY1OGIzNWFmMDNhNmYzNzFlOGMxZmNlYjM3OTA4MDM1ZTkzYjcxN2RmODczJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZyZXNwb25zZS1jb250ZW50LXR5cGU9aW1hZ2UlMkZwbmcifQ.D0Zq0KXX3w3Dof-QPpmD_E9hx5L3u3EfibkU-UHRpqg)](https://private-user-images.githubusercontent.com/161472830/308537268-d3513f4b-da42-4126-b923-78839d9f87c8.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODMwMTc4OTcsIm5iZiI6MTc4MzAxNzU5NywicGF0aCI6Ii8xNjE0NzI4MzAvMzA4NTM3MjY4LWQzNTEzZjRiLWRhNDItNDEyNi1iOTIzLTc4ODM5ZDlmODdjOC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNzAyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDcwMlQxODM5NTdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04YTlkMWVkMGUwMjY5Njc3NDU0ZGY1OGIzNWFmMDNhNmYzNzFlOGMxZmNlYjM3OTA4MDM1ZTkzYjcxN2RmODczJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZyZXNwb25zZS1jb250ZW50LXR5cGU9aW1hZ2UlMkZwbmcifQ.D0Zq0KXX3w3Dof-QPpmD_E9hx5L3u3EfibkU-UHRpqg)

Gabela Framework
================

[](#gabela-framework)

Gabela is a lightweight PHP framework designed to simplify web application development. It follows the MVC (Model-View-Controller) architecture and provides essential tools for building scalable and maintainable applications. This framework is crafted to minimize development complexity and offers developers the freedom to choose their preferred templating language, styling framework (e.g., Bootstrap), and jQuery libraries.

Overview
--------

[](#overview)

Gabela aims to strike a balance between simplicity and flexibility. Here are some key features and principles:

- **Flexibility:** Gabela doesn't impose strict conventions, allowing developers to choose their preferred tools and libraries for templating and styling. Use Bootstrap or any other CSS framework that suits your project.
- **Templating Language:** Gabela provides the freedom to use any templating language of your choice. Whether it's plain PHP or a templating engine like Twig, you have the flexibility to structure your views according to your preference.
- **Security Focus:** Gabela places a strong emphasis on user authentication and ongoing security. It includes features and practices that help developers build secure applications, and it is designed to adapt to evolving security standards.
- **Authentication:** The framework simplifies user authentication, making it easy to implement secure login systems and protect sensitive areas of your application.
- **Modular Structure:** Organize your application into modules for better structure and maintainability. Use the `vendor` directory for third-party modules, and create your modules in a modular structure.
- **Freedom of Choice:** Gabela does not restrict developers to a specific set of tools or libraries. It encourages the use of industry-standard components but gives you the freedom to make choices based on your project's requirements.

Table of Contents
-----------------

[](#table-of-contents)

1. [Installation](#installation)
2. [Getting Started](#getting-started)
3. [Configuration](#configuration)
4. [Routing](#routing)
5. [Controllers](#controllers)
6. [Models](#models)
7. [Views](#views)
8. [Helpers](#helpers)
9. [Middleware](#middleware)
10. [Modules](#modules)
11. [Error Handling](#error-handling)

Installation
------------

[](#installation)

1. Clone the Gabela repository: [https://github.com/your-username/gabela.git](https://github.com/gabela-framework/gabela.git)

    ```
    git clone https://github.com/gabela-framework/gabela.git
    ```
2. Install dependencies using Composer:

    ```
    composer install
    ```
3. Configure your web server to point to the root directory if using apache make sure you change the Base in the .htaccess as required.

Getting Started
---------------

[](#getting-started)

Gabela follows a simple and intuitive structure. The entry point is the `index.php` and also `bootstrap.php` file inside the gabela directory.

Configuration
-------------

[](#configuration)

Configuration settings are stored in the `config` directory. Update the `gabela/config/config.php` file to set environment-specific configurations.

Routing
-------

[](#routing)

Define routes in the `router.php` file. Use the `Gabela\Core\Router` class to map URLs to controller actions.

```
$router->get('/', 'HomeController::index')->pass('guest');
$router->post('/submit', 'FormController::submit')->pass('auth');
$router->post('/admin', 'AdminPageController::Index')->pass('admin');
```

The routing for this framework is quit unique and complex yet easy to implement, the drive for the complex routing is the make sure that we cater for the security of your application by implementing the middleware.

Controllers
-----------

[](#controllers)

- Controllers handle user requests and invoke the corresponding actions. Create controllers in the controllers directory.
- In the `gabela\core` you will fine the abstractClass where renderView and getTemplate methods are declared.

```
class HomeController extends ControllerAbstract
{
    public function index()
    {
        $this->getTemplate('home');
    }
}
```

Models
------

[](#models)

Models represent the data and business logic of your application. Create models in the models directory.

```
class User implements UserInterface
{
    // Model methods here
}
```

Views
-----

[](#views)

Views are stored in the views directory. Use plain HTML or a templating engine for your views.

```

    Welcome to Gabela Framework

```

Helpers
-------

[](#helpers)

Helpers are utility functions that can be used throughout your application. Customize the helpers directory for additional functionality.

```
// helpers/weatherApi.php
function getCurrentWeather()
{
    // Weather fetching logic
}
```

Middleware
----------

[](#middleware)

Middleware provides a convenient mechanism for filtering HTTP requests entering your application. Customize the middleware directory to add middleware.

Modules
-------

[](#modules)

Organize your application into modules for better structure and maintainability. Use the vendor directory for third-party modules. The 1st module created for the framework as a beta is `gabela-users` which you will get with the framework on the installation. you can also install it using composer.

```
composer require gabela/gabela-users
```

You can find the module in the `vendor/gabela/gabela-users`

Error Handling
--------------

[](#error-handling)

Handle errors gracefully using the error handler defined in the ErrorHandler class.

This documentation provides a basic overview of the Gabela framework. Refer to the source code and comments for more detailed information on each component.

For advanced features and customization options, consult the official documentation or the developer community.

Creating Your First Hello World Page in Gabela Framework
--------------------------------------------------------

[](#creating-your-first-hello-world-page-in-gabela-framework)

Step 1: Craft a Controller
==========================

[](#step-1-craft-a-controller)

Begin by crafting a controller class within the `gabela/controllers` directory. Here's a snippet to create the `HelloWorldController`:

```
