PHPackages                             longdhdev/holaframework - 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. longdhdev/holaframework

ActiveProject[Framework](/categories/framework)

longdhdev/holaframework
=======================

A simple php framework

v1.0.9.x-dev(1y ago)10MITPHPPHP &gt;=7.4

Since Apr 30Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/hailong289/hola-framework)[ Packagist](https://packagist.org/packages/longdhdev/holaframework)[ Docs](https://github.com/hailong289/hola-framework.git)[ RSS](/packages/longdhdev-holaframework/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

PHP framework
=============

[](#php-framework)

Getting started
---------------

[](#getting-started)

```
composer create-project longdhdev/project_holaframework

```

```
composer install

```

What new in version v1.0.9
--------------------------

[](#what-new-in-version-v109)

- Add dependency injection
- Refactor namespace
- Model improvements
- Add save, softDelete, pagination, paginationWithCount functions in model
- Add application class
- add registerCommand and app()
- Improve response and queue
- php version &gt;= 8.0

List
----

[](#list)

- [Router](#Router)
- [App](#App)
- [Controller](#Use-controller)
- [Model](#Use-model)
- [View](#Use-view)
- [Middleware](#Use-middleware)
- [Request](#Use-Request)
- [Validate request](#Use-validate-request)
- [Rules](#Rules-can-be-used)
- [Response](#Use-response)
- [Query Builder](#Query-Builder)
- [Relation](#Use-relation)
- [Shared function](#Use-function)
- [Translate](#Use-translate)
- [Queue](#Queue)
- [Mail](#Mail)
- [Command](#Command)

Router
------

[](#router)

- Set up in router/web.php
- Router will receive 2 parameters, 1st parameter will be url, 2nd parameter will be array including controller and function in controller

```
use Hola\Core\Router;
use App\Controllers\HomeController;

Router::get('/', [HomeController::class,'index']);
Router::get('/home', [HomeController::class,'index']);
```

- Use parameters

```
use Hola\Core\Router;
use App\Controllers\HomeController;

// url {domain}/home/1
Router::get('/home/{id}', [HomeController::class,'index']);

// url {domain}/home/detail/2
Router::get('/home/detail/{id}', [HomeController::class,'detail']);
```

- Use router with prefix

```
  Router::prefix('home')->group(function (){
      Router::get('/', [HomeController::class,'index']);
      Router::get('/detail', [HomeController::class,'detail']);
      Router::get('/list', [HomeController::class,'list']);
  });
  // The path will be
  // https://domain.com/home
  // https://domain.com/home/detail
  // https://domain.com/home/list
```

- When you want to create another router file, you can create it in the router folder and then add the code below in router/index.php
- The `add()` function will identify your path and the `loadFile()` function will load the router file you just created

```
use Hola\Core\ConfigRouter;
$configRouter = new ConfigRouter();
$configRouter->add('api')->loadFile('api'); // https://domain.com/api
$configRouter->add('api_v2')->loadFile('api_v2'); // https://domain.com/api_2
// or
$configRouter->add([
    'web' => 'web',
    'api_v2' => 'api'
])->work();
// https://domain.com/web
// https://domain.com/api_v2
```

- Parameters in controller

```
