PHPackages                             dsframework/dsframework - 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. dsframework/dsframework

ActiveProject[Framework](/categories/framework)

dsframework/dsframework
=======================

The Dsframework template for dsframework project

1.0.0(1y ago)135MITHack

Since Oct 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Daevsoft/dsframework)[ Packagist](https://packagist.org/packages/dsframework/dsframework)[ RSS](/packages/dsframework-dsframework/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

PHP DsFramework
===============

[](#php-dsframework)

PHP DsFramework Next Generation MVC framework. Inspired by Laravel and CodeIgniter framework with cutting edge complexity proccess.

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

[](#getting-started)

DsFramework support for PHP 8.1 or latest to work properly.
**Requirements :**

- PHP 8.1 or [latest](https://php.net)
- [Composer](https://getcomposer.org/download/)

### Installation

[](#installation)

To create a new project with dsframework type a `composer create-project dsframework/dsframework mywebfoldername` command in the terminal.

### How to run?

[](#how-to-run)

First, install dependencies from composer with `composer install` command in terminal.
Second, run a project with `php ds serve` command. Done.

### Connect Database

[](#connect-database)

To connecting into database, open the `.env` file and set your database configuration in the name prefix `DB_` property.
**Example:**

```
DB_DRIVER=mysql
DB_HOST=localhost
DB_USERNAME=root
DB_PASSWORD=mypassword
DB_NAME=somethingdb
DB_PORT=3306
SSL_CERT=
SSL_VERIFY=false
```

Leave `DB_NAME` blank if a web application does not require a database.

### ENV File

[](#env-file)

The `.env` file is a constant value for the application configuration. When the file has been modified, refresh the configuration cache with the `php ds config` command in the terminal.

Model
-----

[](#model)

Open terminal and write a command : `php ds add:model modelName`
Or generate multiple model : `php ds add:model modelname1 modelname2 modelnameOther`
Example : `php ds add:model People` then model file `app/models/People.php` will be generated

```
namespace App\Models;

use Ds\Foundations\Connection\Models\DsModel;

class People extends DsModel {
  public $table = 'people';
}
```

Controller
----------

[](#controller)

Open terminal and write a command : `php ds add:controller ControllerName`
Or generate multiple controller : `php ds add:controller controllername1 controllername2 controllernameOther`
Example of controller :

```
class IndexController extends Controller
{
    public function index()
    {
        view('home');
    }

    public function peopleList(){
        $data = People::all();
        // Response is json encode
        return [ 'people_list' => $data ];
    }

    public function savePeople(Request $request){
        // Save json data
        People::save($request->json());
        // OR specify request field
        People::save([
            'fullname' => $request->fullname,
            'phone' => $request->phone
        ]);
        // OR all Request Form Field Data
        People::save($request->all());
    }

    public function welcomePage()
    {
        // Response is Views/Html render
        view('welcome');
    }
}
```

Routing
-------

[](#routing)

The routing of web application is defined in the `app/route/web.php` file. Example :

```
// with callback controller method
Route::get('/', [IndexController::class, 'index']);
Route::get('/welcome', [IndexController::class, 'welcomePage']);
Route::get('/people', [IndexController::class, 'peopleList']);
Route::post('/people/save', [IndexController::class, 'savePeople']);

// simple route
Route::get('/sample/subsample', function () {
    echo 'Welcome to routing!';
});

// With uri as parameter
Route::get('/sample/{arg1}/subsample/{arg2}', function ($arg1, $arg2) {
    echo 'Uri param ' . $arg1 . ' - ' . $arg2;
});
// With middleware
Route::middleware(['auth'], function () {
    Route::get('/mypage/{arg1}/othersub/{mysub}', function ($arg1, $mysub) {
        echo 'page param ' . $arg1 . ' - ' . $mysub;
    });

    Route::get('/mypage/page/{arg1}/{arg2}', function ($arg1, $arg2) {
        echo 'page ' . $arg1 . ' param ' . $arg2;
    });
});
// or with middleware in spacific route
Route::get('/people-list', [ IndexController::class, 'index' ])->middleware('api-auth');
// or multiple middleware
Route::get('/people-list', [ IndexController::class, 'index' ])
            ->middleware([ 'api-auth', 'company-auth' ]);

// With grouping /admin/...
Route::group('admin', function () {
    Route::get('/get-string', function () {
        // will return Json Encode
        return ['username' => 'Deva Arofi'];
    });
});
```

View
----

[](#view)

Open terminal and write a command : `php ds add:view viewname`
Or generate multiple view : `php ds add:view viewname1 viewname2 viewnameOther`
Or generate in subdirectory : `php ds add:view pages/viewname` and `views/pages/` directory will generate automatically.

Example view file : `welcome.pie.php`

```

        {{ $appname }}

        Welcome to Web App

```

### Pie Cheat Sheet

[](#pie-cheat-sheet)

SyntaxClosingDescription`{{ ... }}``-`Same as `echo(...)` in php`>``-`Same as `` in php`@slot(..)``-`Create a slot for templating`@use(..)``-`To use a template that includes `@slot` syntax`@part(..)``@endpart`To inject a content into `@slot(..)``@foreach(..):``@endforeach`Same as `` in phpAdvanced
========

[](#advanced)

Middleware
----------

[](#middleware)

```
class AuthMiddleware implements Middleware
{
    public function handle(Request $request, $next): Response|null
    {
        // if middleware was passed
        if(true){
            return $next($request);
        }else{
            return null;
        }
    }
}
```

Assign middleware into Route

```
Route::get('/all-person', [ PersonController::class, 'index' ])
            ->middleware(['auth']);
```

### Passing data from Middleware to Controller

[](#passing-data-from-middleware-to-controller)

```
class AuthMiddleware implements Middleware
{
    public function handle(Request $request, $next): Response|null
    {
        // find person data by id
        $personData = Person::find($request->person_id);
        // if middleware was passed
        if($personData != null){
            $request->add('person', $personData);
            return $next($request);
        }else{
            return null;
        }
    }
    ...
}
```

Then retrieve data in controller

```
class PersonController extends Controller
{
    public function index(Request $request)
    {
        $person = $request->person;

        var_dump($person);
    }
    ...
}
```

Routing
-------

[](#routing-1)

If you want to grouping routes based on controller, you can write like this : `app/route/web.php`

```
Route::group('/user', UserController::class);
```

Then, in controller class : `app/controllers/UserController.php`

```
class UserController extends Controller
{
    #[Get('/all')]
    public void index()
    {
        ...
    }

    #[Get('/detail/{userId}')]
    public void userById($userId)
    {
        ...
    }

    #[Post('/save')]
    public void saveUser(Request $request)
    {
        ...
    }

    #[Delete('/delete')]
    public void deleteUser()
    {
        ...
    }
}
```

Then, you can access by address like this :
GET | `http://localhost:8000/user/all`
GET | `http://localhost:8000/user/detail/3`
POST | `http://localhost:8000/user/save`
DELETE | `http://localhost:8000/user/delete`

Testing
-------

[](#testing)

Dsframework support for testing and unit test.
Write `php ds add:test SampleTest OtherTest` in terminal, and test file will generate automatically into `\tests` folder.

```
class SampleTest extends TestCase{
  public function test_sample(){
    $expect = 'hello';
    $this->assertTrue('hello' == $expect);
  }
}
```

### Unit Test

[](#unit-test)

Or, using `--unit` options to generate unit test file.
`php ds add:test --unit SampleTest` command.

```
describe('Count is one thousand', function(){
  $count = 0;
  for ($i=0; $i < 1000; $i++) {
    $count += $i;
  }
  return Assert::check($count == 1000);
});
// OR mock DatabaseProvider to support Model
describe('One is one number', function(){
  mock(DatabaseProvider::class);
  $account = Account::find(7);

  return Assert::equal($account->id, 7);
});
```

### Run Test

[](#run-test)

To run your test file, type a command `php ds test` or `php ds test --unit` for unit test file. Then, all test files will be executed.

based on [@daevsoft/dsframework](https://github.com/daevsoft/dsframework)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 82.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

591d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/263d3da697e56ace28ac85dfa100cf95a8d5f073aebc8328d520f7feee93b389?d=identicon)[Daevsoft](/maintainers/Daevsoft)

---

Top Contributors

[![deev-tech](https://avatars.githubusercontent.com/u/252152162?v=4)](https://github.com/deev-tech "deev-tech (19 commits)")[![Daevsoft](https://avatars.githubusercontent.com/u/26130534?v=4)](https://github.com/Daevsoft "Daevsoft (3 commits)")[![devarofi](https://avatars.githubusercontent.com/u/93132581?v=4)](https://github.com/devarofi "devarofi (1 commits)")

---

Tags

backendframeworkmvcphpphpframeworkroutingtemplatingwebphpframeworktemplatingmvcdsframework

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dsframework-dsframework/health.svg)

```
[![Health](https://phpackages.com/badges/dsframework-dsframework/health.svg)](https://phpackages.com/packages/dsframework-dsframework)
```

###  Alternatives

[fluxoft/rebar

Rebar: A simple but sturdy support framework.

2137.9k2](/packages/fluxoft-rebar)[mirekmarek/php-jet

PHP Jet is modern, powerful, real-life proven, really fast and secure, small and light-weight framework for PHP8 with great clean and flexible modular architecture containing awesome developing tools. No magic, just clean software engineering.

241.3k](/packages/mirekmarek-php-jet)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
