Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 DotKernel (https://www.dotkernel.com)
Copyright (c) 2024 Dotkernel (https://www.dotkernel.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DotKernel API
# Dotkernel API

DotKernel API is a PHP skeleton app for building REST APIs using [Laminas](https://github.com/laminas) and [Mezzio](https://github.com/mezzio) components and implements standards like PSR-3, PSR-4, PSR-7, PSR-11 and PSR-15.
Dotkernel API is a PHP skeleton app for building REST APIs using [Laminas](https://github.com/laminas) and [Mezzio](https://github.com/mezzio) components and implements standards like PSR-3, PSR-4, PSR-7, PSR-11 and PSR-15.

Dotkernel API is an alternative for legacy Laminas API Tools (formerly Apigility) applications, and is based on Enrico Zimuel's [Zend Expressive API - Skeleton example](https://github.com/ezimuel/zend-expressive-api).

Expand Down Expand Up @@ -122,13 +122,13 @@ Sending a GET request to the [home page](http://0.0.0.0:8080/) should output the

```text
{
"message": "DotKernel API version 5"
"message": "Dotkernel API version 5"
}
```

## Documentation

In order to access DotKernel API documentation, check the provided [readme file](documentation/README.md).
In order to access Dotkernel API documentation, check the provided [readme file](documentation/README.md).

Additionally, each CLI command available has it's own documentation:

Expand Down
79 changes: 40 additions & 39 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dotkernel/api",
"type": "project",
"description": "DotKernel API",
"description": "Dotkernel API",
"license": "MIT",
"homepage": "https://www.dotkernel.org",
"support": {
Expand All @@ -19,7 +19,7 @@
],
"authors": [
{
"name": "DotKernel Team",
"name": "Dotkernel Team",
"email": "[email protected]"
}
],
Expand Down Expand Up @@ -51,47 +51,48 @@
"php": "~8.2.0 || ~8.3.0",
"ext-gd": "*",
"ext-json": "*",
"dotkernel/dot-cache": "^4.0",
"dotkernel/dot-cli": "^3.5.0",
"dotkernel/dot-data-fixtures": "^1.2.2",
"dotkernel/dot-dependency-injection": "^1.0",
"dotkernel/dot-cache": "^4.3",
"dotkernel/dot-cli": "^3.9.0",
"dotkernel/dot-data-fixtures": "^1.4.0",
"dotkernel/dot-dependency-injection": "^1.2",
"dotkernel/dot-errorhandler": "^4.0.0",
"dotkernel/dot-mail": "^5.1.0",
"dotkernel/dot-response-header": "^3.2.3",
"laminas/laminas-component-installer": "^3.4.0",
"laminas/laminas-config-aggregator": "^1.14.0",
"laminas/laminas-hydrator": "^4.15.0",
"laminas/laminas-inputfilter": "^2.29.0",
"laminas/laminas-stdlib": "^3.19.0",
"mezzio/mezzio": "^3.19.0",
"mezzio/mezzio-authentication-oauth2": "^2.8.0",
"mezzio/mezzio-authorization-acl": "^1.10.0",
"mezzio/mezzio-authorization-rbac": "^1.7.0",
"mezzio/mezzio-cors": "^1.11.1",
"mezzio/mezzio-fastroute": "^3.11.0",
"mezzio/mezzio-hal": "^2.9",
"mezzio/mezzio-problem-details": "^1.13.1",
"mezzio/mezzio-twigrenderer": "^2.15.0",
"dotkernel/dot-mail": "^5.3.0",
"dotkernel/dot-response-header": "^3.4.1",
"laminas/laminas-component-installer": "^3.5.0",
"laminas/laminas-config-aggregator": "^1.18.0",
"laminas/laminas-hydrator": "^4.16.0",
"laminas/laminas-inputfilter": "^2.31.0",
"laminas/laminas-stdlib": "^3.20.0",
"mezzio/mezzio": "^3.20.1",
"mezzio/mezzio-authentication-oauth2": "^2.11.0",
"mezzio/mezzio-authorization-acl": "^1.11.0",
"mezzio/mezzio-authorization-rbac": "^1.8.0",
"mezzio/mezzio-cors": "^1.13.0",
"mezzio/mezzio-fastroute": "^3.12.0",
"mezzio/mezzio-hal": "^2.10",
"mezzio/mezzio-problem-details": "^1.15.0",
"mezzio/mezzio-twigrenderer": "^2.17.0",
"ramsey/uuid-doctrine": "^2.1.0",
"roave/psr-container-doctrine": "^5.2.1",
"symfony/filesystem": "^7.0.3",
"zircote/swagger-php": "^4.10"
"roave/psr-container-doctrine": "^5.2.2",
"symfony/filesystem": "^7.2.0",
"zircote/swagger-php": "^5.0.6"
},
"require-dev": {
"laminas/laminas-coding-standard": "^3.0",
"laminas/laminas-development-mode": "^3.12.0",
"mezzio/mezzio-tooling": "^2.9.0",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-doctrine": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^10.5.10",
"laminas/laminas-coding-standard": "^3.0.1",
"laminas/laminas-development-mode": "^3.13.0",
"mezzio/mezzio-tooling": "^2.10.1",
"phpstan/phpstan": "^2.1.7",
"phpstan/phpstan-doctrine": "^2.0.2",
"phpstan/phpstan-phpunit": "^2.0.4",
"phpunit/phpunit": "^10.5.45",
"roave/security-advisories": "dev-latest",
"symfony/var-dumper": "^7.1"
"symfony/var-dumper": "^7.2.3"
},
"autoload": {
"psr-4": {
"Api\\Admin\\": "src/Admin/src/",
"Api\\App\\": "src/App/src/",
"Api\\Security\\": "src/Security/src/",
"Api\\User\\": "src/User/src/",
"Core\\Admin\\": "src/Core/src/Admin/src/",
"Core\\App\\": "src/Core/src/App/src/",
Expand All @@ -105,12 +106,6 @@
}
},
"scripts": {
"post-update-cmd": [
"php bin/composer-post-install-script.php"
],
"development-disable": "laminas-development-mode disable",
"development-enable": "laminas-development-mode enable",
"development-status": "laminas-development-mode status",
"check": [
"@cs-check",
"@test",
Expand All @@ -119,6 +114,12 @@
"clear-config-cache": "php bin/clear-config-cache.php",
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"development-disable": "laminas-development-mode disable",
"development-enable": "laminas-development-mode enable",
"development-status": "laminas-development-mode status",
"post-update-cmd": [
"php bin/composer-post-install-script.php"
],
"serve": "php -S 0.0.0.0:8080 -t public/",
"static-analysis": "phpstan analyse --memory-limit 1G",
"test": "phpunit --colors=always"
Expand Down
80 changes: 40 additions & 40 deletions config/autoload/authorization.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,50 +30,50 @@
'permissions' => [
AdminRole::ROLE_SUPERUSER => [],
AdminRole::ROLE_ADMIN => [
'admin.my-account.update',
'admin.my-account.view',
'admin.create',
'admin.delete',
'admin.list',
'admin.update',
'admin.view',
'admin.role.list',
'admin.role.view',
'user.activate',
'user.create',
'user.list',
'user.delete',
'user.view',
'user.update',
'user.avatar.create',
'user.avatar.delete',
'user.avatar.view',
'user.role.list',
'user.role.view',
'error.report',
'home',
'admin::list-admin',
'admin::create-admin',
'admin::delete-admin',
'admin::view-admin',
'admin::update-admin',
'admin::list-role',
'admin::view-role',
'admin::view-account',
'admin::update-account',
'user::list-user',
'user::create-user',
'user::delete-user',
'user::view-user',
'user::update-user',
'user::delete-user-avatar',
'user::view-user-avatar',
'user::create-user-avatar',
'user::list-role',
'user::view-role',
'user::activate-user',
'user::deactivate-user',
'app::create-error-report',
'app::view-index',
],
UserRole::ROLE_USER => [
'user.my-account.delete',
'user.my-account.update',
'user.my-account.view',
'user.my-avatar.create',
'user.my-avatar.delete',
'user.my-avatar.view',
'user::delete-account',
'user::view-account',
'user::update-account',
'user::delete-account-avatar',
'user::view-account-avatar',
'user::create-account-avatar',
],
UserRole::ROLE_GUEST => [
'account.activate.request',
'account.activate',
'account.register',
'account.modify-password',
'account.recover-identity',
'account.reset-password.validate',
'account.reset-password.request',
'security.generate-token',
'security.refresh-token',
'error.report',
'home',
'user.create',
'app::create-error-report',
'app::view-index',
'user::activate-account',
'user::request-activate-account',
'user::recover-account',
'user::check-account-reset-password',
'user::update-account-reset-password',
'user::create-account-reset-password',
'user::create-account',
'security::token',
'security::token',
],
],
],
Expand Down
2 changes: 1 addition & 1 deletion config/autoload/cli.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
return [
'dot_cli' => [
'version' => '1.0.0',
'name' => 'DotKernel CLI',
'name' => 'Dotkernel CLI',
'commands' => [
DemoCommand::getDefaultName() => DemoCommand::class,
RouteListCommand::getDefaultName() => RouteListCommand::class,
Expand Down
2 changes: 1 addition & 1 deletion config/autoload/local.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $databases = [

return [
'application' => [
'name' => 'DotKernel API',
'name' => 'Dotkernel API',
'url' => $baseUrl,
'versioning' => [
'documentation_url' => 'https://docs.dotkernel.org/api-documentation/v5/core-features/versioning',
Expand Down
80 changes: 80 additions & 0 deletions config/autoload/mail.global.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

declare(strict_types=1);

return [
/**
* Dotkernel mail module configuration
* Note that many of these options can be set programmatically too, when sending mail messages actually that is
* what you'll usually do, these configs provide just defaults and options that remain the same for all mails
*/
'dot_mail' => [
//the key is the mail service name, this is the default one, which does not extend any configuration
'default' => [
//message configuration
'message_options' => [
//from email address of the email
'from' => '',
//from name to be displayed instead of from address
'from_name' => '',
//reply-to email address of the email
'reply_to' => '',
//replyTo name to be displayed instead of the address
'reply_to_name' => '',
//destination email address as string or a list of email addresses
'to' => [],
//copy destination addresses
'cc' => [],
//hidden copy destination addresses
'bcc' => [],
//email subject
'subject' => '',
//body options - content can be plain text, HTML
'body' => [
'content' => '',
'charset' => 'utf-8',
],
//attachments config
'attachments' => [
'files' => [],
'dir' => [
'iterate' => false,
'path' => 'data/mail/attachments',
'recursive' => false,
],
],
],
/**
* the mail transport to use can be any class implementing
* Symfony\Component\Mailer\Transport\TransportInterface
*
* for standard mail transports, you can use these aliases:
* - sendmail => Symfony\Component\Mailer\Transport\SendmailTransport
* - esmtp => Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport
*
* defaults to sendmail
**/
'transport' => 'sendmail',
//options that will be used only if esmtp adapter is used
'smtp_options' => [
//hostname or IP address of the mail server
'host' => '',
//port of the mail server - 587 or 465 for secure connections
'port' => 587,
'connection_config' => [
//the smtp authentication identity
'username' => '',
//the smtp authentication credential
'password' => '',
//to disable auto_tls set tls key to false
//it's not recommended to disable TLS while connecting to an SMTP server
'tls' => null,
],
],
],
// option to log the SENT emails
'log' => [
'sent' => getcwd() . '/log/mail/sent.log',
],
],
];
1 change: 1 addition & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class_exists(Mezzio\Tooling\ConfigProvider::class)
Core\User\ConfigProvider::class,
Api\Admin\ConfigProvider::class,
Api\App\ConfigProvider::class,
Api\Security\ConfigProvider::class,
Api\User\ConfigProvider::class,

// Load application config in a pre-defined order in such a way that local settings
Expand Down
7 changes: 5 additions & 2 deletions config/pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

declare(strict_types=1);

use Api\App\Handler\NotFoundHandler;
use Api\App\Handler\GetNotFoundViewHandler;
use Api\App\Middleware\AuthenticationMiddleware;
use Api\App\Middleware\AuthorizationMiddleware;
use Api\App\Middleware\ContentNegotiationMiddleware;
use Api\App\Middleware\DeprecationMiddleware;
use Api\App\Middleware\ResponseMiddleware;
use Dot\ErrorHandler\ErrorHandlerInterface;
use Dot\ResponseHeader\Middleware\ResponseHeaderMiddleware;
use Mezzio\Application;
Expand Down Expand Up @@ -79,10 +80,12 @@
// - route-based validation
// - etc.

$app->pipe(ResponseMiddleware::class);

// Register the dispatch middleware in the middleware pipeline
$app->pipe(DispatchMiddleware::class);
// At this point, if no Response is returned by any middleware, the
// NotFoundHandler kicks in; alternately, you can provide other fallback
// middleware to execute.
$app->pipe(NotFoundHandler::class);
$app->pipe(GetNotFoundViewHandler::class);
};
Loading