Skip to content
This repository was archived by the owner on Jun 18, 2023. It is now read-only.

Repository files navigation

API Framework Dewep

skeleton: https://github.com/deweppro/framework-api-skeleton

How to initialize an instance:

<?phpdeclare(strict_types=1);
require_once'./../vendor/autoload.php';
Dewep\Config::setConfigPath(__DIR__.'/../config.yml');
(newDewep\Application())->bootstrap();

A sample configuration file [config.yml]:

To display in the response file in which the error occurred:

debug: true

The answer format for scalar answers is text/html; charset=utf-8, for non - scalar answers::

response: application/json

Routing

You can add routes through the config file

routes:
/{user}/name:
GET,POST,PUT: Dewep\Demo::demo/:
GET: Dewep\Demo::home

Where the placeholder {user} will be passed to the controller as a variable:

publicfunctiondemo(Request$request, string$user) {}

Or you can specify a route generator, which must contain a method - public function handler()

routes: \App\Routes
class Routes
{
publicfunctionhandler()
{
$routes = [];
$routes['/{user}/name']['GET'] = 'Dewep\Demo::demo';
$routes['/{user}/name']['POST'] = 'Dewep\Demo::demo';
$routes['/{user}/name']['PUT'] = 'Dewep\Demo::demo';
$routes['/']['GET'] = 'Dewep\Demo::home';
return$routes;
}
}

Middleware

You can specify the middleware to be executed before and after the main code is executed. Middleware should match the interface \Dewep\Interfaces\MiddlewareInterface

middleware:
before:
cookie: &CookieUserAuth_: \Dewep\Middleware\Auth\Cookiesname: sesssecret: 'demo'exp: 6000000domain: localhostafter:
cookie: *CookieUserAuth

Dependency injection

For dependency injection you can create providers that must match the interface Dewep\Interfaces\ProviderInterface

providers:
logger:
_: Dewep\Providers\LoggerProviderdebug: truename: appfilename: app.logmysql:
_: Dewep\Providers\MysqlProviderhost: localhostport: 3306dbname: defaultlogin: defaultpassword: default

Access to providers occurs through the Container: Container::get('logger')->...

Console

Work with the console occurs through the console application

#!/usr/bin/env php<?php
include_once __DIR__.'/vendor/autoload.php';\Dewep\Config::setConfigPath(__DIR__.'/config.yml');
(new Dewep\Console())->bootstrap();

The console command is added to the config file as follows: command name: class

console:
app.restore: \Dewep\Handlers\Consoles\CreateDirs

All command classes must match the interface \Dewep\Interfaces\ConsoleInterface

Executing a command with parameters:

./console app.restore --demo=hello

View a list of commands:

./console
Commands list: app.restore: Restore the system directory structure.
....

Directory structure

root || app [source code for the application]
| public [public folder]
| database [database migration]]
| resources [templates template engine and data used in the application]
| storage [the preservation of data generated by users and application]
| temp [folder logs and temporary files]
| tests [folder for unit tests]

Releases

Packages

Used by

Contributors

Languages