All Projects → phphleb → hleb

phphleb / hleb

Licence: MIT license
PHP Micro-Framework HLEB

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to hleb

rawphp
A powerful, robust and API-first, PHP framework that helps people from different PHP backgrounds work on the same project seamlessly. You can write Laravel, CakePHP, Slim, Symphone and Procedural PHP code inside it and it all works perfectly. Its the PHP Framework for everyone.
Stars: ✭ 31 (-46.55%)
Mutual labels:  micro-framework, php-framework
Symlex
A lean framework stack for agile Web development based on Symfony and Vuetify
Stars: ✭ 278 (+379.31%)
Mutual labels:  micro-framework, php-framework
Azkarra Streams
🚀 Azkarra is a lightweight java framework to make it easy to develop, deploy and manage cloud-native streaming microservices based on Apache Kafka Streams.
Stars: ✭ 146 (+151.72%)
Mutual labels:  micro-framework
php-interview-questions
PHP Basics ( v8.x )
Stars: ✭ 192 (+231.03%)
Mutual labels:  php-framework
Laravel Zero
A PHP framework for console artisans
Stars: ✭ 2,821 (+4763.79%)
Mutual labels:  micro-framework
Flight
An extensible micro-framework for PHP
Stars: ✭ 2,396 (+4031.03%)
Mutual labels:  micro-framework
sparkjava-war-example
Build war with maven and sparkjava framework
Stars: ✭ 20 (-65.52%)
Mutual labels:  micro-framework
Slim
Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
Stars: ✭ 11,171 (+19160.34%)
Mutual labels:  micro-framework
Mind
Mind is the PHP code framework designed for developers. It offers a variety of solutions for creating design patterns, applications and code frameworks.
Stars: ✭ 30 (-48.28%)
Mutual labels:  php-framework
Mini3
Just an extremely simple naked PHP application, useful for small projects and quick prototypes.
Stars: ✭ 231 (+298.28%)
Mutual labels:  micro-framework
velox
The minimal PHP micro-framework.
Stars: ✭ 55 (-5.17%)
Mutual labels:  php-framework
Mu
A tweet-sized PHP micro-router
Stars: ✭ 229 (+294.83%)
Mutual labels:  micro-framework
Nutz
Nutz -- Web Framework(Mvc/Ioc/Aop/Dao/Json) for ALL Java developer
Stars: ✭ 2,422 (+4075.86%)
Mutual labels:  micro-framework
KikimR
KikimR the fast PHP micro-framework
Stars: ✭ 13 (-77.59%)
Mutual labels:  micro-framework
Legibleerror
Beating `Error.localizedDescription` at its own game.
Stars: ✭ 156 (+168.97%)
Mutual labels:  micro-framework
aleph
A simple PHP framework for very small sites
Stars: ✭ 14 (-75.86%)
Mutual labels:  php-framework
Micro Graphql
GraphQL Microservice
Stars: ✭ 145 (+150%)
Mutual labels:  micro-framework
fir
Fir. A lightweight PHP MVC Framework.
Stars: ✭ 33 (-43.1%)
Mutual labels:  php-framework
Version
semver (Semantic Version) Swift µFramework.
Stars: ✭ 228 (+293.1%)
Mutual labels:  micro-framework
landing
Landing Page Framework
Stars: ✭ 36 (-37.93%)
Mutual labels:  php-framework

HLEB

HLEB LOGO

PHP Micro-Framework

Requires PHP version 7.0 or higher (including version 8).

Link to instructions (RU)

Routing > Controllers > Models > Page Builder > Debug Panel

A distinctive feature of the micro-framework HLEB is the minimalism of the code and the speed of work. The choice of this framework allows you to launch a full-fledged product with minimal time costs and appeals to documentation; it is easy, simple and fast. At the same time, it solves typical tasks, such as routing, shifting actions to controllers, model support, so, the basic MVC implementation. This is the very minimum you need to quickly launch an application.

Installation

To start the mini-framework HLEB

  1. Download the folder with the project from its original location.

Using Composer:

$ composer create-project phphleb/hleb
  1. Assign the address of the resource to the "public" subdirectory.
  2. Establish the rights to allow changes for web server for the "storage" folder and all folders and files within it.

Upon completion of these steps, you can verify installation by typing the resource address assigned earlier (locally or on a remote server) in the address bar of the browser. If installation is successful, a parked page with the framework logo will be displayed.

List of standard console commands:

$ cd hleb
$ php console --help

Customization

Command character constants in the micro-framework HLEB are set in the start.hleb.php file. Initially, a file with this name does not exist and must be copied from the default.start.hleb.php file in the same project root directory.

Attention! Constant HLEB_PROJECT_DEBUG enables/disables debug mode. Do not use debug mode on a public server.

Routing

Project routes are compiled by the developer in the "/routes/main.php" file, other files with routes from the "routes" folder can be inserted (included) into this file, which together constitute a routing map.

Routes are determined by class Route methods, the main of which is get(). All methods of this class are available and used only in the routing map.

Attention! Route files are cached and should not contain any code containing external data.

Route::get('/', 'Hello, world!');

Display the contents of the "/views/index.php" file using the view() function (also available in controllers).

Route::get('/', view('index'));

This is an example of a more complex-named route. Here, $x and $y values are transferred to the "/views/map/new.php" file, and conditions for the dynamic address are set ("version" and "page" can take different values). You can call a route up by its name using dedicated functions of the framework.

Route::get('/ru/{version}/{page?}/', view('/map/new', ['x' => 0, 'y' => 0]))->where(['version' => '[a-z0-9]+', 'page' => '[a-z]+'])->name('RouteName'); // /ru/.../.../ or /ru/.../

or (with IDE hints)

Route::get('/ru/{version}/{page?}/', view('/map/new', ['x' => 0, 'y' => 0]))::where(['version' => '[a-z0-9]+', 'page' => '[a-z]+'])::name('RouteName'); // /ru/.../.../ or /ru/.../

Special tag @ for categories or users

Route::get('/@{user}/', view('profile'));

Get different query options

Route::get('/example/...0-5/', '0 to 5 parts');

Groups of routes

Methods located before a route or group:

type()->, prefix()->, protect()->, before()->, domain()->

Route::prefix('/lang/')->before('AuthClassBefore')->getGroup();
  Route::get('/page/', "<h1>Page</h1>"); // GET /lang/page/
  Route::protect()->post('/ajax/', '{"connect":1}'); // POST /lang/ajax/ 
Route::endGroup();

Methods located after a route or group:

->where(), ->after()

Route::type(['get','post'])->before('ClassBefore')->get('/path/')->controller('ClassController')->after('ClassAfter');

Controllers

Creating a simple controller with such content:

// File /app/Controllers/TestController.php
namespace App\Controllers;
use App\Models\UserModel;
class TestController extends \MainController
{
    function index($status) {  // $status = 'friends'
      $data = UserModel::getUserData(\Request::get('id'), $status);
      return view('/user/profile', ['contacts' => $data]);
    }
}

You can use it in the route map:

Route::get('/profile/{id}/contacts/')->controller('TestController',['friends'])->where(['id' => '[0-9]+']);

or

Route::get('/profile/{id}/contacts/')->controller('TestController@index',['friends'])->where(['id' => '[0-9]+']);

Replacing class and method calls from url:

Route::get('/example/{class}/{method}/')->controller('<class>Controller@get<method>'); // Converts `site.com/example/all-users/user/` to `AllUsersController@getUser`

Models

// File /app/Models/UserModel.php
namespace App\Models;
class UserModel extends \MainModel
{
  static function getUserData(int $id, string $status) {
    $data = /* ... */ // A query to the database, returning users data.
    return $data;
  }
}

Modules

For modular development, you need to create the folder 'modules'.

  • /modules
    • /example
      • /DefaultModuleController.php (or 'Controller.php' without specifying the controller in the route)
      • /content.php
      • /templates
        • /origin.php
Route::get('/test/module/example/')->module('example', 'DefaultModuleController');
// File /modules/example/DefaultModuleController.php (similar to standard controller)
namespace Modules\Example;
class DefaultModuleController extends \MainController
{
   function index() {
      return view('content');
   }
}
// File /modules/example/content.php
insertTemplate('/example/templates/origin');

Templates

// File /resources/views/content.php
insertTemplate('templates/origin', ['title' => 'Short text', 'content' => 'Long text']);
// File /resources/views/templates/origin.php
echo $title; // Short text
echo $content; // Long text

Page Builder

Route::renderMap('#Header_map', ['/parts/header', '/parts/resources']);
Route::renderMap('#Footer_map', ['/parts/reviews', '/parts/footer']);

Route::get('/', render(['#Header_map', '/pages/index', '#Footer_map'], ['variable' => 'value']));

Optional use of Twig template engine

$ composer require "twig/twig:^3.0"
Route::get('/template/', view('templates/map.twig', ['variable' => 'value']));

Debug Panel

WorkDebug::add($debug_data, 'description');

Database queries

Recommended phphleb/xdorm ORM or DB (add-on over PDO) class.

Additional features


version Total Downloads License: MIT PHP PHP Build Status Tweet

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].