gabela / micro-framework
This the next big thing in the php frameworks community
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Type:project
Requires
- aternus/geonames-client: ^2.3
- gabela/gabela-payfast: ^1.0
- gabela/gabela-users: ^1.0
- gabela/tasks: ^1.2
- monolog/monolog: ^3.5
- payfast/payfast-php-sdk: ^1.1
- phpmailer/phpmailer: ^6.9
- vlucas/phpdotenv: ^5.6
- dev-main
- 1.4.8
- 1.4.7
- 1.4.6
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.9
- 1.2.7
- 1.2.4
- dev-gabela-dynamic-forms
- dev-gabela-latest-changes
- dev-branch-134
- dev-branch-133
- dev-branch-132
- dev-EVENT-MANAGER
- dev-gabela-framework-patch-3
- dev-gabela-framework-patch-2
- dev-branch-1.3
- dev-branch-1.2.9
- dev-branch-1.2.8
- dev-branch-1.2.7
- dev-branch-1.2.5
- dev-dev-1.2.4
- dev-gabela-framework-patch-1
This package is auto-updated.
Last update: 2025-03-13 18:29:40 UTC
README
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
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
- Installation
- Getting Started
- Configuration
- Routing
- Controllers
- Models
- Views
- Helpers
- Middleware
- Modules
- Error Handling
Installation
-
Clone the Gabela repository: https://github.com/your-username/gabela.git
git clone https://github.com/gabela-framework/gabela.git
-
Install dependencies using Composer:
composer install
-
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
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 settings are stored in the config
directory. Update the gabela/config/config.php
file to set environment-specific configurations.
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 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 represent the data and business logic of your application. Create models in the models directory.
class User implements UserInterface { // Model methods here }
Views
Views are stored in the views directory. Use plain HTML or a templating engine for your views.
<!-- views/home.php --> <html> <body> <h1>Welcome to Gabela Framework</h1> </body> </html>
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 provides a convenient mechanism for filtering HTTP requests entering your application. Customize the middleware directory to add middleware.
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
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
Step 1: Craft a Controller
Begin by crafting a controller class within the gabela/controllers
directory. Here's a snippet to create the HelloWorldController
:
<?php namespace Gabela\Controller; class HelloWorldController extends \Gabela\Core\AbstractController { public function Action() { // Your controller logic goes here printValue('Hello World'); } }
Step 2: Configure Your Router
In the router.php
file, configure the routing for your new page:
$router->get("{$extensionPath}/hello-world", "HelloWorldController::Action")->pass('guest');
Step 3: Add Namespace and Path
In the gabela/config/GabelaPathsConfig.php
file, integrate the namespace and path for your controller:
'HelloWorldController' => [ 'namespace' => 'Gabela\\Controller\\', 'path' => BASE_PATH . '/gabela/controllers/', ],
Now you're all set! Navigate to your page at http://site.local/hello-world and witness your "Hello World" message in action.