Skip to content

Commit a9cd7bc

Browse files
committed
updated readme and changes for quodana
Signed-off-by: Claudiu Pintiuta <claudiupintiuta@gmail.com>
1 parent 6fd52d3 commit a9cd7bc

2 files changed

Lines changed: 89 additions & 114 deletions

File tree

README.md

Lines changed: 88 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,25 @@
33
DotKernel web starter package suitable for admin applications.
44

55
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/admin)
6-
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/admin/4.3.1)
6+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/admin/5.0.0)
77

88
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/admin)](https://github.com/dotkernel/admin/issues)
99
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/admin)](https://github.com/dotkernel/admin/network)
1010
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/admin)](https://github.com/dotkernel/admin/stargazers)
11-
[![GitHub license](https://img.shields.io/github/license/dotkernel/admin)](https://github.com/dotkernel/admin/blob/3.0/LICENSE.md)
11+
[![GitHub license](https://img.shields.io/github/license/dotkernel/admin)](https://github.com/dotkernel/admin/blob/5.0/LICENSE.md)
1212

13-
[![Build Static](https://github.com/dotkernel/admin/actions/workflows/static-analysis.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/admin/actions/workflows/static-analysis.yml)
14-
[![Build Static](https://github.com/dotkernel/admin/actions/workflows/run-tests.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/admin/actions/workflows/run-tests.yml)
13+
[![Build Static](https://github.com/dotkernel/admin/actions/workflows/continuous-integration.yml/badge.svg?branch=5.0)](https://github.com/dotkernel/admin/actions/workflows/continuous-integration.yml)
1514
[![codecov](https://codecov.io/gh/dotkernel/admin/graph/badge.svg?token=BQS43UWAM4)](https://codecov.io/gh/dotkernel/admin)
16-
[![Qodana](https://github.com/dotkernel/admin/actions/workflows/qodana_code_quality.yml/badge.svg)](https://github.com/dotkernel/admin/actions/workflows/qodana_code_quality.yml)
15+
[![Qodana](https://github.com/dotkernel/admin/actions/workflows/qodana_code_quality.yml/badge.svg?branch=5.0)](https://github.com/dotkernel/admin/actions/workflows/qodana_code_quality.yml)
1716

1817
[![SymfonyInsight](https://insight.symfony.com/projects/6a7ecfc1-a0ed-4901-96ac-d0ff61f7b55f/big.svg)](https://insight.symfony.com/projects/6a7ecfc1-a0ed-4901-96ac-d0ff61f7b55f)
1918

20-
21-
# Installing DotKernel `admin`
22-
23-
- [Installing DotKernel `admin`](#installing-dotkernel-admin)
24-
- [Installation](#installation)
25-
- [Composer](#composer)
26-
- [Choose a destination path for DotKernel `admin` installation](#choose-a-destination-path-for-dotkernel-admin-installation)
27-
- [Installing the `admin` Composer package](#installing-the-admin-composer-package)
28-
- [Installing DotKernel admin](#installing-dotkernel-admin)
29-
- [Configuration - First Run](#configuration---first-run)
30-
- [Manage GeoLite2 database](#manage-geolite2-database)
31-
- [Testing (Running)](#testing-running)
19+
## Installing DotKernel `admin`
3220

3321
## Tools
3422

35-
DotKernel can be installed through a single command that utilizes [Composer](https://getcomposer.org/). Because of that, Composer is required to install DotKernel `admin`.
36-
23+
DotKernel can be installed through a single command that utilizes [Composer](https://getcomposer.org/). Because of that,
24+
Composer is required to install DotKernel `admin`.
3725

3826
### Composer
3927

@@ -42,32 +30,29 @@ Installation instructions:
4230
- [Composer Installation - Linux/Unix/OSX](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx)
4331
- [Composer Installation - Windows](https://getcomposer.org/doc/00-intro.md#installation-windows)
4432

45-
> If you have never used composer before make sure you read the [`Composer Basic Usage`](https://getcomposer.org/doc/01-basic-usage.md) section in Composer's documentation
46-
33+
>If you have never used composer before make sure you read
34+
>the [`Composer Basic Usage`](https://getcomposer.org/doc/01-basic-usage.md) section in Composer's documentation
4735
48-
## Choosing an installation path for DotKernel `admin`
36+
## Choosing an installation path for DotKernel `admin`
4937

5038
Example:
5139

5240
- absolute path `/var/www/dk-admin`
5341
- or relative path `dk-admin` (equivalent with `./dk-admin`)
5442

55-
5643
## Installing DotKernel `admin`
5744

58-
After choosing the path for DotKernel (`dk-admin` will be used for the remainder of this example) it must be installed. There are two installation methods.
59-
45+
After choosing the path for DotKernel (`dk-admin` will be used for the remainder of this example) it must be installed.
46+
There are two installation methods.
6047

61-
#### I. Installing DotKernel `admin` using composer
48+
### I. Installing DotKernel `admin` using composer
6249

63-
#### NOTE
64-
> please use the below CLI commands in terminal, do NOT use the PhpStorm buttons
50+
>please use the below CLI commands in terminal, do NOT use the PhpStorm buttons
6551
6652
The advantage of using this command is that it runs through the whole installation process. Run the following command:
6753

6854
composer create-project dotkernel/admin -s dev dk
6955

70-
7156
The above command downloads the `admin` package, then downloads and installs the `dependencies`.
7257

7358
The setup script prompts for some configuration settings, for example the lines below:
@@ -77,8 +62,8 @@ The setup script prompts for some configuration settings, for example the lines
7762
[1] config/config.php
7863
Make your selection (default is 1):
7964

80-
81-
Simply select `[0] Do not inject`, because DotKernel includes its own configProvider which already contains the prompted configurations.
65+
Simply select `[0] Do not inject`, because DotKernel includes its own configProvider which already contains the prompted
66+
configurations.
8267

8368
If you choose `[1] config/config.php` Laminas's `ConfigProvider` from `session` will be injected.
8469

@@ -88,48 +73,44 @@ The next question is:
8873

8974
Type `y` here, and hit `enter`
9075

76+
### II. Installing DotKernel `admin` using git clone
9177

92-
#### II. Installing DotKernel `admin` using git clone
93-
94-
This method requires more manual input, but it ensures that the default branch is installed, even if it is not released. Run the following command:
78+
This method requires more manual input, but it ensures that the default branch is installed, even if it is not released.
79+
Run the following command:
9580

9681
git clone https://github.com/dotkernel/admin.git .
9782

98-
9983
The dependencies have to be installed separately, by running this command
10084

10185
composer install
10286

103-
104-
Just like for `II Installing DotKernel admin using composer` (see above), the setup asks for configuration settings regarding injections (type `0` and hit `enter`) and a confirmation to use this setting for other packages (type `y` and hit `enter`)
105-
87+
Just like for `II Installing DotKernel admin using composer` (see above), the setup asks for configuration settings
88+
regarding injections (type `0` and hit `enter`) and a confirmation to use this setting for other packages (type `y` and
89+
hit `enter`)
10690

10791
## Configuration - First Run
10892

10993
- Remove the `.dist` extension from the files `config/autoload/local.php.dist`
11094
- Edit `config/autoload/local.php` according to your dev machine and fill in the `database` configuration
11195

11296
Run the migrations and seeds with these commands:
113-
```shell
114-
php bin/doctrine-migrations migrate
115-
```
116-
```shell
117-
php bin/doctrine fixtures:execute
118-
```
119-
120-
- If you use `composer create-project`, the project will go into development mode automatically after installing. The development mode status can be checked and toggled by using these composer commands:
121-
```shell
122-
composer development-status
123-
```
124-
```shell
125-
composer development-enable
126-
```
127-
```shell
128-
composer development-disable
129-
```
97+
98+
php bin/doctrine-migrations migrate
99+
100+
php bin/doctrine fixtures:execute
101+
102+
- If you use `composer create-project`, the project will go into development mode automatically after installing. The
103+
development mode status can be checked and toggled by using these composer commands:
104+
105+
composer development-status
106+
107+
composer development-enable
108+
109+
composer development-disable
130110

131111
- If not already done on installation, remove the `.dist` extension from `config/autoload/development.global.php.dist`.
132-
This will enable dev mode by turning debug flag to `true` and turning configuration caching to `off`. It will also make sure that any existing config cache is cleared.
112+
This will enable dev mode by turning debug flag to `true` and turning configuration caching to `off`. It will also
113+
make sure that any existing config cache is cleared.
133114

134115
> Charset recommendation: utf8mb4_general_ci
135116
@@ -139,56 +120,55 @@ You can download/update a specific GeoLite2 database, by running the following c
139120

140121
php bin/cli.php geoip:synchronize -d {DATABASE}
141122

142-
143123
Where _{DATABASE}_ takes one of the following values: `asn`, `city`, `country`.
144124

145125
You can download/update all GeoLite2 databases at once, by running the following command:
146126

147127
php bin/cli.php geoip:synchronize
148128

149-
150-
The output should be similar to the below, displaying per row: `database identifier`: `previous build datetime` -> `current build datetime`.
129+
The output should be similar to the below, displaying per
130+
row: `database identifier`: `previous build datetime` -> `current build datetime`.
151131

152132
> asn: n/a -> 2021-07-01 02:09:34
153-
>
133+
>
154134
> city: n/a -> 2021-07-01 02:09:20
155-
>
135+
>
156136
> country: n/a -> 2021-07-01 02:05:12
157137
158138
Get help for this command by running:
159139

160140
php bin/cli.php help geoip:synchronize
161141

162-
163-
**Tip**: If you setup the synchronizer command as a cronjob, you can add the `-q|--quiet` option, and it will output data only if an error has occurred.
164-
142+
**Tip**: If you setup the synchronizer command as a cronjob, you can add the `-q|--quiet` option, and it will output
143+
data only if an error has occurred.
165144

166145
## NPM Commands
167146

168147
To install dependencies into the `node_modules` directory run this command.
169148

170149
npm install
171150

172-
173-
If `npm install` fails, this could be caused by user permissions of npm. Recommendation is to install npm through `Node Version Manager`.
151+
If `npm install` fails, this could be caused by user permissions of npm. Recommendation is to install npm
152+
through `Node Version Manager`.
174153

175154
The watch command compiles the components then watches the files and recompiles when one of them changes.
176155

177156
npm run watch
178157

179-
180-
After all updates are done, this command compiles the assets locally, minifies them and makes them ready for production.
158+
After all updates are done, this command compiles the assets locally, minifies them and makes them ready for production.
181159

182160
npm run prod
183161

184-
185162
## Authorization Guards
186-
The packages responsible for restricting access to certain parts of the application are [dot-rbac-guard](https://github.com/dotkernel/dot-rbac-guard) and [dot-rbac](https://github.com/dotkernel/dot-rbac). These packages work together to create an infrastructure that is customizable and diversified to manage user access to the platform by specifying the type of role the user has.
187163

188-
The `authorization.global.php` file provides multiple configurations specifying multiple roles as well as the types of permissions to which these roles have access.
164+
The packages responsible for restricting access to certain parts of the application
165+
are [dot-rbac-guard](https://github.com/dotkernel/dot-rbac-guard) and [dot-rbac](https://github.com/dotkernel/dot-rbac).
166+
These packages work together to create an infrastructure that is customizable and diversified to manage user access to
167+
the platform by specifying the type of role the user has.
168+
169+
The `authorization.global.php` file provides multiple configurations specifying multiple roles as well as the types of
170+
permissions to which these roles have access.
189171

190-
```php
191-
//example of a flat RBAC model that specifies two types of roles as well as their permission
192172
'roles' => [
193173
'superuser' => [
194174
'permissions' => [
@@ -205,44 +185,41 @@ The `authorization.global.php` file provides multiple configurations specifying
205185
]
206186
]
207187
]
208-
```
209188

210-
The `authorization-guards.global.php` file provides configuration to restrict access to certain actions based on the permissions defined in `authorization.global.php` so basically we have to add the permissions in the dot-rbac configuration file first to specify the action restriction permissions.
189+
The `authorization-guards.global.php` file provides configuration to restrict access to certain actions based on the
190+
permissions defined in `authorization.global.php` so basically we have to add the permissions in the dot-rbac
191+
configuration file first to specify the action restriction permissions.
211192

212-
```php
213-
//example of configuration example to restrict certain actions of some routes based on the permissions specified in the dot-rbac configuration file
214193
'rules' => [
215-
[
216-
'route' => 'account',
217-
'actions' => [//list of actions to apply , or empty array for all actions
218-
'unregister',
219-
'avatar',
220-
'details',
221-
'changePassword'
222-
],
223-
'permissions' => ['authenticated']
224-
],
225-
[
226-
'route' => 'admin',
227-
'actions' => [
228-
'deleteAccount'
229-
],
230-
'permissions' => [
231-
'delete'
232-
//list of roles to allow
233-
]
234-
]
194+
[
195+
'route' => 'account',
196+
'actions' => [//list of actions to apply , or empty array for all actions
197+
'unregister',
198+
'avatar',
199+
'details',
200+
'changePassword'
201+
],
202+
'permissions' => ['authenticated']
203+
],
204+
[
205+
'route' => 'admin',
206+
'actions' => [
207+
'deleteAccount'
208+
],
209+
'permissions' => [
210+
'delete'
211+
//list of roles to allow
212+
]
213+
]
235214
]
236-
```
237215

238216
## Testing (Running)
239217

240218
Note: **Do not enable dev mode in production**
241219

242220
- Run the following command in your project's directory to start PHPs built-in server:
243-
```shell
244-
php -S 0.0.0.0:8080 -t public
245-
```
221+
222+
php -S 0.0.0.0:8080 -t public
246223

247224
> Running command `composer serve` will do the exact same, but the above is faster.
248225
@@ -255,8 +232,8 @@ If you are still getting exceptions or errors regarding some missing services, t
255232

256233
php bin/clear-config-cache.php
257234

258-
259-
> If `config-cache.php` is present that config will be loaded regardless of the `ConfigAggregator::ENABLE_CACHE` in `config/autoload/mezzio.global.php`
235+
> If `config-cache.php` is present that config will be loaded regardless of the `ConfigAggregator::ENABLE_CACHE`
236+
> in `config/autoload/mezzio.global.php`
260237
261238
- Open a web browser and visit `http://localhost:8080/`
262239

@@ -268,16 +245,14 @@ If you ran the migrations you will have an admin user in the database with the f
268245
- **Password**: `dotadmin`
269246

270247
**NOTE:**
248+
271249
- **Production only**: Make sure you modify the default admin credentials.
272250
- **Development only**: `session.cookie_secure` does not work locally so make sure you modify your `local.php`, as per the following:
273-
```php
274-
# other code
275-
276-
return [
277-
# other configurations...
278-
'session_config' => [
279-
'cookie_secure' => false,
280-
],
281-
];
282-
```
251+
252+
return [
253+
'session_config' => [
254+
'cookie_secure' => false,
255+
]
256+
];
257+
283258
Do not change this in `local.php.dist` as well because this value should remain `true` on production.

src/Setting/src/Service/SettingService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Frontend\Setting\Entity\Setting;
1010
use Frontend\Setting\Repository\SettingRepository;
1111

12-
class SettingService
12+
readonly class SettingService
1313
{
1414
#[Inject(
1515
SettingRepository::class,

0 commit comments

Comments
 (0)